i have a table in my database as freespace... it has a column called freesize with its datatype as int.
i have three valuse in it :
1065189988
1073741818
1073741819
now i try to get the total free space but i get an error.
private void GetFreeSpace()
{
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection();
connection.ConnectionString = ConfigurationManager.ConnectionStrings["SumooHAgentDBConnectionString"].ConnectionString;
connection.Open();
SqlCommand sqlCmd = new SqlCommand("select sum(freesize)* 0.000000000931322575 as freespace from freespace", connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dt);
connection.Close();
if (dt.Rows.Count > 0)
{
double freeSpace = Convert.ToDouble(dt.Rows[0]["freespace"].ToString());
}
}
Arithmetic overflow error converting expression to data type int.
Line 123: SqlCommand sqlCmd = new SqlCommand("select sum(freesize)* 0.000000000931322575 as freespace from freespace", connection);
Line 124: SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
Line 125: **sqlDa.Fill(dt);** here i get error
Line 126: connection.Close();
Line 127: if (dt.Rows.Count > 0)
Any suggestions of how to get the value in freespace without changing the datatype?
Thanks
I know it works good with bigint, but I want int.