In backend there is a column named as NetValue having datatype as VARCHAR(20). The value which is get saved in the column is 4999988224 without any decimal. While reading this value in the frontend via ExecuteReader is showing error "System.Data.SqlClient.SqlException: 'Arithmetic overflow error for type int, value = 4999988224.000000. The statement has been terminated". A procedure get executed at the backend and I have tried by casting the column in BIGINT & VARCHAR(20) as well within Select query. But in both cases it is showing me same error.
Below is the code of ExecuteReader method which is causing error:
public static SqlDataReader ExecuteReader(string cmdText, CommandType type, SqlParameter[] prms)
{
SqlConnection conn = new SqlConnection(connectionString);
using (SqlCommand cmd = new SqlCommand(cmdText, conn))
{
cmd.CommandType = type;
if (prms != null)
{
foreach (SqlParameter p in prms)
{
cmd.Parameters.Add(p);
}
}
conn.Open();
return cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
}
The variable in which I am returning the value is also defined as String type. Same way in home also I am displaying total sum and that sum total figure is 5007015226. This is also retrieved using same by casting in BIGINT, this has retrieved successfully.
Why is this showing me overflow error ? KIndly help.