SQL语句执行没问题
public bool DeleteUser(string userid)
{string strSQL = "delete from tb_Users where UserId in (" + userid + ")";
return dbbase.ExecuteNonQuery(false, strSQL,null);
}
用存储过程执行出问题了,说无法将string类型转换为int32,问题出在存储过程上面:
public static int DeleteUser(string userid )
{
int ret = 0;
string spName = "TY_DeleteUser";
object[] para = new object[] { userid };
ret = DataAccess.ExecuteNonQuery(spName, false, para);
return ret;
}
错误存储过程写法:
create proc TY_DeleteUser
(@UserId int)
as
delete from tb_Users where UserId in (@UserId)
正确存储过程写法(动态SQL)
create proc TY_DeleteUser
(@UserId nvarchar(250))
as
Exec('delete from tb_Users where UserId in('+@UserId+')' )
以上是菜鸟级问题,知道的就不用看了,不懂的可以看下,谢谢。。。。。