日期:2014-05-18 浏览次数:20834 次
string Sql = "INSERT INTO tbGuestBook (UserName,PostTime,Message,IsReplied,Reply)VALUES('"+tb_username.Text+"','"+DateTime.Now+"','"+tb_message.Text+"',0,'')" //这里如果只写SQL语句 就应该是 ...VALUES("tb_username.Text","DateTime.Now","tb_message.Text",0,"") //外面加上个双引号的话 里面的双引号用单引号替代 "...VALUES('tb_username.Text','DateTime.Now','tb_message.Text',0,'')" //然后字符串和String类型的变量间用+号连接起来 "...VALUES('+tb_username.Text+','+DateTime.Now+','+tb_message.Text+',0,'')" //再然后+号和字符串常量之间加个"将常量字符串分隔 "...VALUES('"+tb_username.Text+"','"+DateTime.Now+"','"+tb_message.Text+"',0,'')"