TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rajkumar R
NA
183
220.6k
data table sum function in asp.net
Nov 5 2011 5:59 AM
private void BindGrid()
{
// Set your connection String here
SqlConnection cn = new SqlConnection("Data Source=.;Initial Catalog=Demo_eLogsVA4;Integrated Security=True");
//Write a select Query
cn.Open();
string q = "Select Convert(nVarchar,A.Rec_No) CRec,A.Acc_Name Descr,A.Quantity Qty,Convert(nVarchar,A.Sell_Rate) SRate,Sell_CName Sname , Sell_CCode SCCode, Sell_CValue SCValue ,Convert(nVarchar,A.Quantity*A.Sell_Rate*Sell_CValue) SAmount, A.Service_Tax STax,Convert(nVarchar,(A.Quantity*A.Sell_Rate*Sell_CValue)* A.Service_Tax/100)Tax_Amount,Convert(nVarchar,((A.Quantity*A.Sell_Rate*Sell_CValue)+(A.Quantity*A.Sell_Rate*Sell_CValue)* A.Service_Tax/100)) Net From eLogs_Invoice_Charges_Details A Where A.Invoice_Code='INV991'";
DataSet dset = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(q, cn);
DataTable dtable = new DataTable();
da.Fill(dtable);
//Bind grid.
GridView1.DataSource = dtable;
//object sumobject = Convert.ToInt32(dtable.Compute("SUM(Net)", ""));
GridView1.DataBind();
GridView1.FooterRow.Cells[10].Text = dset.Tables[0].Compute("sum(Net)", "").ToString();
cn.Close();
}
Here i m getting the following error
Exception Details:
System.IndexOutOfRangeException: Cannot find table 0.
Plaese post the solution for me
Reply
Answers (
2
)
Returning multiple rows for class (OOP)
Create category and subcategory