读书人

请问下面这段代码为什么出现 CS201异

发布时间: 2012-01-28 22:06:13 作者: rapoo

请教,下面这段代码为什么出现 CS201错误呢?网速慢,搜索了麻烦啊,恳请大家指教
SqlConnection conn = new SqlConnection( "server=(local); "+ "Database=bbs; "+ "Integrated Security=true; ");


SqlCommand cmd = new SqlCommand();
cmd.CommandText = "INSERT INTO post(name,subject,message,[date],ip) Values ( ' "; strName + " ', ' " + strSubject + " '. ' " + strMsg + " ', ' " + strDate + " ', ' " + strIP + " '); ";
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();

[解决办法]
try:
cmd.CommandText = "INSERT INTO post(name,subject,message,[date],ip) Values ( ' "+ strName + " ', ' " + strSubject + " ', ' " + strMsg + " ', ' " + strDate + " ', ' " + strIP + " ') ";

读书人网 >asp.net

热点推荐