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 .
Loading
Pravin MorePosted Sep 21, 2011, 8:51 AM
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.