执行到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();
} 展开
{
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();
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询