Hi Everyone,
I would like to retrieve the aggregate functions data as bulk ,but i would like use sql dataadapter.
Please suggest me the code.I am describing the sql query.
select MAX(nooftimes ),MAX(scoredmarks),min(scoredmarks),avg(scoredmarks),avg(totalmarks) from studlist where name ='bill gates'
I would like use SQL dataadapter , Datareader .
Bulk aggregate functions with dataadapter or datareader
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Pravin MoreRank #1,419 · 1.2K reputationPosted Sep 21, 2011, 4:51 AM EDT
string nooftimes="", maxscoredmarks="",minscoredmarks="",avgscoredmarks="",totalmarks="";
SqlConnection con=new SqlConnection(yourConnectionString);
string str="select MAX(nooftimes ),MAX(scoredmarks),min(scoredmarks),avg(scoredmarks),avg(totalmarks) from studlist where name ='bill gates'";
SqlDataReader dr;
con.Open();
SqlCommand cmd=new SqlCommand(str,Con);
dr=cmd.ExecuteReader();
while(dr.Read())
{
nooftimes=Convert.ToInt32(dr[0]);
maxscoredmarks=Convert.ToInt32(dr[1]);
minscoredmarks=Convert.ToInt32(dr[2]);
avgscoredmarks=Convert.ToInt32(dr[3]);
totalmarks=Convert.ToInt32(dr[4]);
}
thats it....hope this will solve your problem..!!!
Thankx,
Pravin.