当前位置: 代码迷 >> Sql Server >> 帮看一条SQL语句,错哪了
  详细解决方案

帮看一条SQL语句,错哪了

热度:34   发布时间:2016-04-27 11:12:55.0
帮看一条SQL语句,哪里错了
string strupdate = "insert into table16 (title,username,time,content,class) values (" + TextBox1.Text.ToString() + " , " + "' 1 '" + " ,"+ DateTime.Now+ ", " + TextBox4.Text.ToString() + " , " + "'1'" + " )";
就是上面这句,求指教

------解决方案--------------------
C# code
--字符串都要加单引号引起来的string strupdate = "insert into table16 (title,username,time,content,class) values ('" + TextBox1.Text.ToString() + "' , " + "' 1 '" + " ,'"+ DateTime.Now+ "', '" + TextBox4.Text.ToString() + "' , " + "'1'" + " )";
------解决方案--------------------
试试把DateTime.Now改为DateTime.Now.ToString()
------解决方案--------------------
拼出来的句子 字符串和日期要有单引号,你的没有
  相关解决方案