Dataset math

G

Graeme

Hi.I'm lost.

Winforms, ADO.Net, VB.Net

Have a datagrid which is populated with a subset of my table using SQL
query. What I want is the total of one column ("Sales") which I need to
write into a textbox.

Have had no success so far.

Thanks for any help.
Graeme
 
W

William Ryan eMVP

The computer method should do it for you...
Dim i As Integer =
CType(AllData.Tbl_Job_Tracking.Compute("SUM(Line_Count_1)", "Line_Count_1
=0"), Integer)
someTextBox.Text = i.ToString("#,##0.00")
 
G

Graeme

Thanks Ryan. I'm learning, but still haven't a clue how to use this. I think
....
I rename Tbl_Job_Tracking to my table name
AllData?? Line_Count_1??
Not sure where to fit this method into code. Can you help further?
Thanks
Graeme

Line_Count_1
 
M

Miha Markic [MVP C#]

Hi Greame,

AllData is dataset to which table Tbl_Job_Tracking belongs.
If your table is standalone (not a part of dataset) you can omit alldata.
part.
Line_Count_1 is field that has to be sumarized.

Use this method when you need to compute the sum (probably before outputing
the result).
 
G

Graeme

Cool! Well, that took me about 2 days or searching old threads to no avail.
But this works perfectly! Thanks both!!!

Miha Markic said:
Hi Greame,

AllData is dataset to which table Tbl_Job_Tracking belongs.
If your table is standalone (not a part of dataset) you can omit alldata.
part.
Line_Count_1 is field that has to be sumarized.

Use this method when you need to compute the sum (probably before outputing
the result).

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Graeme said:
Thanks Ryan. I'm learning, but still haven't a clue how to use this. I think
...
I rename Tbl_Job_Tracking to my table name
AllData?? Line_Count_1??
Not sure where to fit this method into code. Can you help further?
Thanks
Graeme

Line_Count_1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top