해결 : 나는 내 자신의 문제를 알아 냈다. 내가 생각한대로 일하고 있었다. 방금 올바른 행을 읽지 못했습니다.SQL 업데이트가 실제로 업데이트되지 않습니까? 완료
표 [프로필]에서 행의 일부 열을 업데이트하려고합니다. 이 코드를 실행할 때 어떤 오류도 발생하지 않지만 실제로 열을 업데이트하지는 않습니다. 전에 업데이트를 사용한 적이 없습니다. 내가 도대체 뭘 잘못하고있는 겁니까.
string currentPage = Request.Url.ToString();
Uri myUri = new Uri(currentPage);
string position = HttpUtility.ParseQueryString(myUri.Query).Get("position");
string electionYear = HttpUtility.ParseQueryString(myUri.Query).Get("year");
var finalkey = Session["Userid"].ToString() + "^" + position + "^" + electionYear;
string sqlquery = "UPDATE [Profiles] SET [email protected], [email protected], [email protected], [email protected] where [email protected]";
SqlConnection conn = new SqlConnection(dbLocation);
SqlCommand comm = new SqlCommand(sqlquery, conn);
try
{
conn.Open();
comm.Parameters.AddWithValue("@FinalKey", finalkey);
comm.Parameters.AddWithValue("@Qualifications", qualificationsBox.Text);
comm.Parameters.AddWithValue("@Platform", platformBox.Text);
comm.Parameters.AddWithValue("@FamilyLife", familyBox.Text);
comm.Parameters.AddWithValue("@Website", candWebsiteBox.Text);
comm.ExecuteNonQuery();
}
catch { }
conn.Close()
왜'catch {}'인가? 어떤 일이 생기면 무엇이 잘못되었는지 알고 싶지 않습니까? 이것은 아마 당신의 문제 일 것입니다. 무엇인가 잘못되었지만 그것을 무시하고 있습니다! –
FinalKey가 실제로 그 형식입니까? 가정 할 때, 중단 점을 넣고 단계별로 실행하십시오. 그래도 업데이트 쿼리가 제대로 보입니다. 아마도 잡기에 잡히고 아무것도 던지지 않을 것입니다. – sgeddes
catch {}에 아무 것도 없을 때 오류가 발생하지 않는다는 것을 어떻게 알 수 있습니까? 예를 들어 – MethodMan