转义符号
string Sql = "INSERT INTO tbGuestBook (UserName,PostTime,Message,IsReplied,Reply) VALUES
('" +tb_username.Text+ "','" + DateTime.Now + "','" + tb_message.Text + "',0,'')";
这里的'" 和"' 是怎么回事,我知道是'的意思,可是没有找见完全的说明
那里有完整的转义符号规则
[解决办法]
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,'')"