MyException - 我的异常网
当前位置:我的异常网» Sql Server » sql语句,语法异常

sql语句,语法异常

www.MyException.Cn  网友分享于:2013-02-20  浏览:4次
sql语句,语法错误
数据库更新是有错误,  下断点之后基本锁定在这条sql语句上
                 sql = string.Format(@"update AnsPaper set Ans1="
                           + ansanswer[0].Text + ",Ans2="
                           + ansanswer[1].Text + ",Ans3="
                           + ansanswer[2].Text + ",Ans4="
                           + ansanswer[3].Text + ",Ans5="
                           + ansanswer[4].Text + ",Ans6="
                           + ansanswer[5].Text + " where PaperNum=" + papernum + "");
总是报错:','附近有语法错误

同样的,另一个类似的语句却能够执行,眼都看花了,也没找出错误
下面是正确的
                    sql = string.Format(@"update Paper set Ans1="
                          + ansnum[0] + ",Ans2="
                          + ansnum[1] + ",Ans3="
                          + ansnum[2] + ",Ans4="
                          + ansnum[3] + ",Ans5="
                          + ansnum[4] + ",Ans6="
                          + ansnum[5] + " where PaperNum=" + papernum + "");
sql语句 update sql 语句 update

------解决方案--------------------
sql = string.Format(@"update AnsPaper set Ans1='"
                           + ansanswer[0].Text + "',Ans2='"
                           + ansanswer[1].Text + "',Ans3='"
                           + ansanswer[2].Text + "',Ans4='"

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有