vb.net Calculate total column from database

Associate
Joined
7 Nov 2008
Posts
1,410
Location
Edinburgh, Scotland
Hey there,

I'm New'ish to vb.net but having a bit of trouble with my program.

I'm currently writing a program for college (atm machine simulator) but I'm having a bit of trouble working out how to add all the rows up in a specific column from a database which houses the 'account details' to allow me to work out the maximum £ of all the accounts.

My tutor was saying that I must use an array to do it as a new account could be created at any time :mad: thus increasing the total again.


What iv been using so far for other ds stuff is this code
Code:
ds.Tables("AccountRecord").Rows(index).Item(7)

Can I use something like
Code:
ds.Tables("AccountRecord").[B]columns[/B](index).Item(7)



Is that too vague ?

Doing my nut in haha

Hope someone will understand!

Thanks in advance :)
 
LinQ to the rescue..

(Paraphrased from C#, and somewhat guessing what your examples are using)

Code:
int total = ds
    .Tables("AccountRecord")
    .Rows(index)
    .Sum( eachRow => eachRow("columnName") )
 
Back
Top Bottom