日期:2014-05-18  浏览次数:20378 次

修改密码时,用到以下代码,结果,0000变为0,出什么问题了?
修改密码时,用到以下代码,结果,0000变为0,出什么问题了?

  string strconn = ConfigurationManager.ConnectionStrings["paisoft_water_db"].ConnectionString;
  string strcmd = "UPDATE [admin_login] SET [ad_pwd] = " + TextBox3.Text + " WHERE [ad_id] = " + Session["ad_id"] +"AND [ad_pwd] = " + TextBox1.Text;
  SqlConnection conn = new SqlConnection(strconn);
  SqlCommand cmd = new SqlCommand(strcmd, conn);
  conn.Open();
  cmd.ExecuteNonQuery();
  conn.Close();


输入密码为000时,数据库却为0,把TextBox3.Text 改为TextBox3.Text.ToString() 也不行!

------解决方案--------------------
C# code
        string strcmd = "UPDATE [admin_login] SET [ad_pwd] = '" + TextBox3.Text + "' WHERE [ad_id] = " + Session["ad_id"]  +"AND [ad_pwd] = '" + TextBox1.Text+"'";