Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C和SQL Server将int转换为数据类型numeric时出现算术溢出错误_C#_Sql Server_Ado.net - Fatal编程技术网

C# 使用C和SQL Server将int转换为数据类型numeric时出现算术溢出错误

C# 使用C和SQL Server将int转换为数据类型numeric时出现算术溢出错误,c#,sql-server,ado.net,C#,Sql Server,Ado.net,我正在开发一个web应用程序,并使用下面的代码调用具有insert语句的存储过程 SqlConnection conn = new SqlConnection(connstr); conn.Open(); SqlCommand command = new SqlCommand(); command.Connection = conn; command.CommandType = CommandType.StoredProcedure; command.CommandText = "Stored

我正在开发一个web应用程序,并使用下面的代码调用具有insert语句的存储过程

SqlConnection conn = new SqlConnection(connstr);
conn.Open();

SqlCommand command = new SqlCommand();
command.Connection = conn;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "StoredProc1";

SqlDataAdapter adapter = new SqlDataAdapter();

SqlParameter parm = new SqlParameter("@ReturnValue", SqlDbType.Int);
parm.Direction = ParameterDirection.ReturnValue;

command.Parameters.Add(parm);

command.Parameters.Add(new SqlParameter("@A", SqlDbType.BigInt)).Value = gui.A;
command.Parameters.Add(new SqlParameter("@B", SqlDbType.Int)).Value = gui.B;
command.Parameters.Add(new SqlParameter("@C", SqlDbType.Decimal)).Value = gui.C;
command.Parameters.Add(new SqlParameter("@D", SqlDbType.Float)).Value = gui.D;
command.Parameters.Add(new SqlParameter("@E", SqlDbType.Float)).Value = gui.E;
command.Parameters.Add(new SqlParameter("@F", SqlDbType.NVarChar)).Value = gui.F;

command.ExecuteNonQuery();

conn.Close();

returnValue = Convert.ToInt32(parm.Value);
但是我犯了个错误

将int转换为数据类型numeric时出现算术溢出错误

在ExecuteOnQuery行上。我能知道我错过了什么吗

谢谢
Anjanaa

实际问题并不完全在.NET中:

检查存储过程,以查看是否有任何计算值可能超过特定类型的大小,即可以计算数据类型int的列,使其与数据类型bigint的大小相等。将包含该信息的药剂应具有相同的数据类型,即,如果该信息包含在临时表中,则临时表应包含该大小的列以包含该数据,如果使用变量,则该变量的大小应可能包含该数据,等等

将包含该数据的属性/字段/变量应为类似的数据类型,即smallint-sql=short-.NET等


显示gui类。还显示存储过程参数声明