C# Update语句不工作
由于某些原因,密码没有更新 您忘记执行查询:C# Update语句不工作,c#,asp.net,C#,Asp.net,由于某些原因,密码没有更新 您忘记执行查询: protected void Button6_Click(object sender, EventArgs e) { Random rnd = new Random(); string resetpassword = rnd.Next(5000, 100000).ToString(); SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionS
protected void Button6_Click(object sender, EventArgs e)
{
Random rnd = new Random();
string resetpassword = rnd.Next(5000, 100000).ToString();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HealthDBContext"].ConnectionString);
conn.Open();
string reset = "UPDATE Users SET" + " Password=@pass" + " WHERE UserName=@user";
SqlCommand com = new SqlCommand(reset, conn);
com.Parameters.AddWithValue("@pass", resetpassword);
com.Parameters.AddWithValue("@user", TextBox1.Text);
conn.Close();
}
该方法返回受影响的行数。您忘记执行查询:
protected void Button6_Click(object sender, EventArgs e)
{
Random rnd = new Random();
string resetpassword = rnd.Next(5000, 100000).ToString();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HealthDBContext"].ConnectionString);
conn.Open();
string reset = "UPDATE Users SET" + " Password=@pass" + " WHERE UserName=@user";
SqlCommand com = new SqlCommand(reset, conn);
com.Parameters.AddWithValue("@pass", resetpassword);
com.Parameters.AddWithValue("@user", TextBox1.Text);
conn.Close();
}
该方法返回受影响的行数。执行查询
int cnt = com.ExecuteNonQuery();
执行查询
int cnt = com.ExecuteNonQuery();
哦,请告诉我,在真实的应用程序中,您没有以纯文本形式存储密码代码>,仅当您正在插入,
删除
,更新
时;etcOoooh,请告诉我,您没有在实际应用程序中以纯文本形式存储密码代码>,仅当您正在插入,删除
,更新
时;埃卡!谢谢总是忘记那句话:(啊!谢谢!总是忘记那句话:(