i have a table wchich has two columns named as 'sl.no.' and 'total'
and it has 5 values in rows like
sl.no total
1 3
2 5
3 2
4 3
5 4
now i want to add only the rows starts from sl.no -2 to sl.no -4
i an using this code but its not working please let me out
object sumobject
for (p = 2; p <= 4; p++)
{
DataTable dt;
dt = dsu.Tables[username.Text];
sumobject = dt.Compute("sum(total)", "sl.no=" + p + "");
}
reasoning0.Text = sumobject.ToString();
Abhay ShankerPosted Dec 25, 2013, 8:28 AM
get datatable as below query
select * from tablename orderby sl.no
int sum=0;
for(i=0;i<3;i++)
sum=sum+convert.toint32(dt.rows[i+1]["total"])
Tirthak ShahPosted Dec 25, 2013, 8:21 AM
"select sum(total) from test where [sl.no] between 2 and 4"
And Execute it it will return a column (Total).
Thanks And Regards,
Tirthak Shah