Vb 6

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 22, 2009, 02:23 PM
430786 members and 297909 Topics
Latest Member: kichu563
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Vb 6
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Vb 6  (Read 122 views)
bigafees
Vb 6
« on: July 20, 2009, 06:48 PM »

pls can any body help me with code on how to add subtotal of numbers in the database in VB6 using MS Access
Big Star (m)
Re: Vb 6
« #1 on: July 21, 2009, 03:06 PM »

Chairman, i can see the help you rendered on searching the data base. That means you are averagely done

DIM TOTALSCORE as INTEGER
REM Assuming the column SCORE had been declare to take interger
TOTALSCORE = 0
WHILE rs.moveNext()
            TOTALSCORE = TOTALSUM + !SCORE
WEND
It been long i coded in vb6.0. The code might not be error free. because i always face the problem of using on programming language style in another untill when the compiler rejects it. Thanks
luckyCO
Re: Vb 6
« #2 on: July 22, 2009, 11:58 AM »

dim db as new adob.connection
dim rs as new adob.recordset
dim subTotalValue as long

db.connection="your conection string"
db.open
set rs=db.execute("Select sum(subtotal) from <your table>")
subTotalValue=rs.fields(0).value
rs.close
db.close

Hope this solves your problem
If it didnt hit http://www.nairaland.com/nigeria/topic-60292.0.html and explain your questions there, if need be I will write a sample and sent it to you.

Take care and bye for now.

dotzok
Re: Vb 6
« #3 on: July 23, 2009, 10:20 AM »

The second solution above is super. I assumed you have connected to your Db already and already making use of a Recordset,

DIm Sum as double, i as inteher
' This is what the first responder meant
for i = 1 to rs_mee.Recordset.Recordcount
     sum = sum + rs_mee.RecordSet.Fields("number")  'your column to sum
     rs_mee.Recordset.Movenext
next i
F5
luckyCO
Re: Vb 6
« #4 on: July 24, 2009, 10:14 AM »

The second solution above is super. I assumed you have connected to your Db already and already making use of a Recordset,

DIm Sum as double, i as inteher
' This is what the first responder meant
for i = 1 to rs_mee.Recordset.Recordcount
     sum = sum + rs_mee.RecordSet.Fields("number")  'your column to sum
     rs_mee.Recordset.Movenext
next i
F5

why do you think looping is better in database where SQL can solve the same problem.
Consider having 10m records and you loop to get the subtotal, what will happen if you need to do many time by may people on the network?

db.connection="your conection string"
db.open
set rs=db.execute("Select sum(subtotal) from <your table>")
subTotalValue=rs.fields(0).value
rs.close
db.close

with the above code the system will assume as if you are opening and fetching the database at the same time sums your subtotal and your result will be returned to you, even if you are querying by many people.

plz dont alway depend on loop as if you are writing QBASIC where SQL can handle the same job!
tolubonnke
Re: Vb 6
« #5 on: July 29, 2009, 11:19 AM »

can someone help me with linking vb6.0 and mssql server 2000 and mysql too. i've been having lots of problem creating a database tht works fine with vb on both.
 Do You Have A Business Application/solution Development Project You Want To Exec  Printing Vb Codes At Once  New Online Affilliate Company   Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.