当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - SQL Update not actually updating? Done

问题描述:

SOLVED: I figured out my own issue. It was working as I thought. I just was not reading the correct row.

I am trying to update a few columns in a row, in the Table [Profiles]. I don't get any errors when running this code but it doesn't actually update the columns. I have never used an update before. What am I doing wrong.

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()

网友答案:

Please refer the value of finalkey by set break Point ! Only Possible for Not Updating is,

There is no matching record found with this finalkey value.

another option

set where class value manually Like where finalvalue="user1dec" and check if it is work, then u can........

var finalkey = Session["Userid"].ToString() + "^" + position + "^" + electionYear;

分享给朋友:
您可能感兴趣的文章:
随机阅读: