SQL多行删除语句

来源:百度知道 编辑:UC知道 时间:2024/05/05 15:21:16
public static bool DeleteMore(string stuNo)
{
string sql = "delete from stuinfo where stuNo in @stuNo";
SqlParameter[] param=new SqlParameter[]
{
new SqlParameter("@stuNo",stuNo)
};
int count = DBHelper.ExecuteCommand(sql, param);
if (count > 0)
{
return true;
}
else
{
return false;
}
}

报错 @stuNo附近有错误,哪里写错了,我不知道啊
在将 varchar 值 '+@stuno+' 转换成数据类型 int 时失败。

错误原因是这个,应该怎么改?
string @stuno=('152','456')
delete from stuinfo where stuno in ('152','456')这样写就对

delete from stuinfo where stuno in ('+@stuno+')这样就报上面的错

别把双引号也去掉了
如果你的@stuno输入是【152,456】的,那语句去掉单引号就好了,写成
string sql = "delete from stuinfo where stuno in ("+@stuno+")";

定义了@stuNo吗?

是不是少了个分号?

SqlParameter[] param=new SqlParameter[]
{
new SqlParameter("@stuNo",stuNo) .....
};