Click here to Skip to main content
14,983,791 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
After doing this one:
SQL
SELECT TOP 10 * FROM [tablename] ORDER BY bid desc


I need to get the average in C#. please provide me code. Thanks in advance
Posted

1 solution

on your datareader iteration, do the following to compute for average.

C#
int total = 0;
whie(dr.Read())
{
   total += Convert.ToInt32(dr[0]);
}
int ave = total / 10;


Regards,
Eduard
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900