我正在开发一个ASP.NET应用程序,并将一个字符串值“1,2,3,4”传递给一个过程,以选择那些IN(1,4)的值,但它说“转换失败时转换varchar值’1,4’到数据类型int.“
private void fillRoles() { /*Read in User Profile Data from database */ Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetStoredProcCommand("sp_getUserRoles"); db.AddInParameter(cmd,"@pGroupIDs",System.Data.DbType.String); db.SetParameterValue(cmd,"1,4"); IDataReader reader = db.ExecuteReader(cmd); DropDownListRole.DataTextField = "Group"; DropDownListRole.DataValueField = "ID"; while (reader.Read()) { DropDownListRole.Items.Add((new ListItem(reader[1].ToString(),reader[0].ToString()))); } reader.Close(); }
这是我的程序:@H_502_3@
CREATE Procedure [dbo].[sp_getUserRoles](@pGroupIDs varchar(50)) AS BEGIN SELECT * FROM CheckList_Groups Where id in (@pGroupIDs) END