日期:2014-05-17  浏览次数:20501 次

帮看一条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()
------解决方案--------------------
拼出来的句子 字符串和日期要有单引号,你的没有