这句更新数据库的语句该怎么写?
错误提示:字符串 无where id = 2 之前有未闭合的引号。第 1 行: 无where id = 2 附近有语法错误。
请朋友们指点指点
我是想通过datagrid中的更新按钮来更新数据库
有关语句如下
string sql_edit = "update aa " + "set bb = " + cc.replace("","")+ "where id = " + e.item.cells[0].text;
sqlcommand sqlcommandupdate = new sqlcommand(sql_edit,connupdate);
参考文章:
用response.write(sql_edit);
resposne.end();输出一下sql_edit就知道了,估计是cc.replace("","")没有返回你想要得值。我感觉应该是cc.replace("","")吧
改成
string sql_edit = "update aa " + "set bb = " + cc.replace("","")+ " where id = " + e.item.cells[0].text;
看语句你没有写这个引号
即set bb =
string sql_edit = "update aa " + "set bb = " + cc.replace("","")+ " where id = " + e.item.cells[0].text;
where前少了一个单引号
"where id = " + e.item.cells[0].text;
where前面加个引号试试
Posted in noname. Edit