传过来的值为:21,1,5,23
数据库字段Oid为数字型自增字段
程序:
string Oid = Request.Form[ "idList "].ToString().Trim();
SqlCommand cmdd = new SqlCommand( "Del ",conn);
cmdd.CommandType = CommandType.StoredProcedure;
cmdd.Parameters.Add(new SqlParameter( "@Userid ",Userid));
cmdd.Parameters.Add(new SqlParameter( "@Oid ",Oid));
cmdd.ExecuteNonQuery();
存储过程:
@Oid varchar(20)
delete OfferList where Userid=@Userid and Oid in (@Oid)
基本上是这样的
提示错误:将 varchar 值 '149,33,147,142,141,1 ' 转换为数据类型为 int 的列时发生语法错误。
请大哥们帮忙,怎么办?
------解决方案--------------------------------------------------------
存储过程:
@Oid varchar(20)
declare @sql varchar(max)
set @sql= 'delete OfferList where Userid=@Userid and Oid in ( '+@Oid+ ') '
exec(@sql)
------解决方案--------------------------------------------------------
顶
------解决方案--------------------------------------------------------
string Oid replace( ", ", " ")再试下
----------------------------------------------------
纯.Net在线图像处理工具XPaint-> http://www.crossgo.com
------解决方案--------------------------------------------------------
帮顶
------解决方案--------------------------------------------------------
149,33,147,142,141,1 这可不是int型吧