hi Developers ,
i want to know How to Calculate Decimal values of All Rows From a Table in C# .
already i have done following query
SqlConnection con = Connection.DBConn();
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand("[select * from Sales where Totalsales='"Ses_Sales""']", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
string sum_QuantityDespatched = dt.Compute("Sum(quantitydespatched)", "").ToString();
above query is working fine. But the problem is it is only working with Integer values.
if the values of table have 3 rows
Value = 1=10
Value = 2=20.
Value = 3=30
i got the my expected output is like = 60:
but if i give the decimal values like this
Value = 1=10.50
Value = 2=20.70
Value = 30=30.00
My expected output is 61.20 . but it throws error.
i want to calculate all rows of a table with Decimal Values . How can i done this task .
anyone know how to done this task please suggest me
Thanking You
Paul.S


Nitin SontakkeRank #264 · 9.6K reputationPosted Feb 27, 2017, 12:26 AM EST
Amit GuptaRank #190 · 12.8K reputationPosted Feb 26, 2017, 11:23 PM EST
Rafnas T PRank #280 · 8.8K reputationPosted Feb 27, 2017, 12:05 AM EST
Nitin SontakkeRank #264 · 9.6K reputationPosted Feb 26, 2017, 10:34 PM EST
Paul RajsRank #2,423 · 582 reputationPosted Feb 28, 2017, 8:07 PM EST
i got exact output friends .
howecer thanks a lot for all your valuable reply dear friends and brothers
by
Paul.S