C# 中调用存储过程报错“ 将参数值从 String 转换到 Int32 失败。”

2025-01-05 16:05:36
推荐回答(2个)
回答1:

myCommand.Parameters.Add("@GroNO", SqlDbType.Int);
myCommand.Parameters["@GroNO"].Value = "select GroNO from zb where grono = (select min(grono) from zb where flag<>2)";

@GroNO接受整型,但是你传的是字符串

回答2:

myCommand.Parameters["@GroNO"].Value = "select GroNO from zb where grono = (select min(grono) from zb where flag<>2)";
Value 要赋值Int类型的、、、、