首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

请问,下面这段代码为什么出现 CS201异常呢?网速慢,搜索了麻烦啊恳请大家指教

2012-01-28 
请教,下面这段代码为什么出现 CS201错误呢?网速慢,搜索了麻烦啊,恳请大家指教SqlConnectionconnnewSqlCon

请教,下面这段代码为什么出现 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 + " ') ";

热点排行