关于存储过程字段的问题,提示参数值超出范围
存储过程如下:
Createproc dbo.test
(
@para1 numeric(22,10)
)
as
select * from userlist
.net代码如下:
SqlParameter para = new SqlParameter( "@para1 ", SqlDbType.Decimal);
para.Scale = 10;
para.Size = 32;
para.Value = 12;
int i = para.Scale;
int j = para.Size;
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
SqlCommand com = new SqlCommand( "test ",conn);
com.Parameters.Add(para);
try
{
com.ExecuteNonQuery();
}
catch (Exception ex)
{
}
finally { conn.Close(); }
执行的时候提示 { "Parameter value '12.0000000000 ' is out of range. "}
怎么解决???
[解决办法]
去掉para.size,改为
para.precision=32