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

protectedvoidGvpw_RowUpdating(objectsender,GridViewUpdateEventArgse){TextBoxtxt_num=(... 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();
}
展开
 我来答
麟o0
2012-05-31
知道答主
回答量:28
采纳率:0%
帮助的人:18.5万
展开全部
string sqlstr = "update stuff set row_num = '" + row_num + "', name = " + name + ", zizhi = " + zizhi + ", jixing = " + jixing + ", duty = " + duty + " where name = '" + name + "'";
中 你有些用 ' ',有些不用,都是string
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式