执行SQL语句时出现错误 请各位看看错哪儿了,我看了一下午了,谢谢了
string gai = "update guandao set 制造日期 = '" + TextBox2.Text + "',安装日期 = '" + TextBox3.Text + "',管径 = '" + TextBox4.Text + "', 壁厚 = '" + TextBox5.Text + "',埋深 = '" + TextBox6.Text + "',腐蚀控制 = '" + TextBox7.Text + "',运行压力 = '" + TextBox8.Text + "' where 管道ID = '" + TextBox1.Text + "' ";
        SqlCommand cmd = new SqlCommand(gai, con);
        cmd.ExecuteNonQuery();
错误是:未处理的sqlexception‘,’附近有语法错误。

解决方案 »

  1.   


    这么写。。自己都难看。。用参数化sql语句吧不想改。。打个断点在string gai上看看生成的sql语句是什么样子的。。
      

  2.   

    把这个复制到你的程序里执行            string gai = "update guandao set 制造日期 = '" + TextBox2.Text + "',安装日期 = '" + TextBox3.Text + "',管径 = '" + TextBox4.Text + "', 壁厚 = '" + TextBox5.Text + "',埋深 = '" + TextBox6.Text + "',腐蚀控制 = '" + TextBox7.Text + "',运行压力 = '" + TextBox8.Text + "' where 管道ID = '" + TextBox1.Text + "' ";
      

  3.   


    sql语句参数化示例。。
      

  4.   

    是不是传递的参数有问题?或者断点调试一下,得到SQL语句,然后到数据库中执行一下,看看是什么错误。
      

  5.   

    还是设断点,查出SQL语法 ,再弄到SQL环境下调试!