c# textbox中输入的数据对SQL2000数据修改出错误,希望高人帮忙解释什么错误。

来源:百度知道 编辑:UC知道 时间:2024/06/08 17:32:37
private void button1_Click(object sender, EventArgs e)
{
if (this.textBox1.Text == "" || this.textBox2.Text == "" || this.textBox3.Text == "" || this.textBox4.Text == "")
{
MessageBox.Show("信息还没有填写完整呢!", "错误提示");
}
else
{
if (this.textBox4.Text == this.textBox3.Text)
{
try
{
string connstr = "Data Source=.;Initial Catalog=yhglxt;Integrated Security=True";
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
SqlCommand cmd = new SqlCommand("UPDATE [Table_connect] SET [password] = '" + this.textBox3.Text.Trim() + "' WHERE [username]="+this.textBox1.Text.Trim(),

SqlCommand cmd = new SqlCommand("UPDATE [Table_connect] SET [password] = '" + this.textBox3.Text.Trim() + "' WHERE [username]='"+this.textBox1.Text.Trim() +"'", conn);

楼上的对了 ,加上引号就是字符串,如果不加就是 int 了