Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Update语句不工作_C#_Asp.net - Fatal编程技术网

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,请告诉我,您没有在实际应用程序中以纯文本形式存储密码,仅当您正在插入,
删除
更新
时;埃卡!谢谢总是忘记那句话:(啊!谢谢!总是忘记那句话:(