执行到cmd.ExecuteNonQuery();句时提示错误信息:',' 附近有语法错误。 求前辈指导 多谢多谢 代码段如下:

protected void Gvpw_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox txt_num = (TextBox)Gvpw.Rows[e.RowIndex].Cells[0].FindControl("TextBox1");
string row_num = txt_num.Text.Trim();

TextBox txt_name = (TextBox)Gvpw.Rows[e.RowIndex].Cells[0].FindControl("TextBox2");
string name = txt_name.Text.Trim();

TextBox txt_zizhi = (TextBox)Gvpw.Rows[e.RowIndex].Cells[0].FindControl("TextBox3");
string zizhi = txt_zizhi.Text.Trim();
TextBox txt_jixing = (TextBox)Gvpw.Rows[e.RowIndex].Cells[0].FindControl("TextBox4");
string jixing = txt_jixing.Text.Trim();

TextBox txt_duty = (TextBox)Gvpw.Rows[e.RowIndex].Cells[0].FindControl("TextBox5");
string duty = txt_duty.Text.Trim();
SqlConnection myconn = new SqlConnection(paiban_conn.paiban_ConnString);
string sqlstr = "update stuff set row_num = '" + row_num + "', name = " + name + ", zizhi = " + zizhi + ", jixing = " + jixing + ", duty = " + duty + " where name = '" + name + "'";
SqlCommand cmd = new SqlCommand(sqlstr, myconn);
myconn.Open();

Response.Write(sqlstr);

cmd.ExecuteNonQuery();

// Response.Write(sqlstr);

myconn.Close();
Gvpw.EditIndex = -1;
Gvpw_Bind();
}

string sqlstr = "update stuff set row_num = '" + row_num + "', name = " + name + ", zizhi = " + zizhi + ", jixing = " + jixing + ", duty = " + duty + " where name = '" + name + "'";
中 你有些用 ' ',有些不用,都是string
温馨提示:答案为网友推荐,仅供参考
相似回答