从我从 textbox1、textbox2 获得的输入中,我想检查 DB,如果给定的用户名和密码组合可用,那么我想用 textbox3 中可用的输入更新密码。以下是我的代码,但似乎我的更新语句无法正常工作,请帮助我更正它...
protected void Button1_Click(object sender, EventArgs e)
{
MySqlConnection connection = new MySqlConnection("server=localhost; database=e-learningsystem; uid=root; password=123;port=3307;");
connection.Open();
try
{
MySqlCommand cmd1 = new MySqlCommand("UPDATE lecturer Set Password= '" + TextBox3.Text + "' WHERE UserName='" + TextBox1.Text + "' AND Password='" + TextBox2.Text + "'", connection);
cmd1.ExecuteNonQuery();
if (cmd1.ExecuteNonQuery() > 0)
{
Response.Write(@"<script language='javascript'>alert('Your Password Has Been Changed successfully!, Congratulations!')</script>");
}
else
{
Response.Write(@"<script language='javascript'>alert('Your Password Has Not Been Changed successfully!, Sorry!')</script>");
}
connection.Close();
}
catch (Exception ex)
{
Response.Write(@"<script language='javascript'>alert(ex.Message)</script>");
}
}