Reading from a database

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2009
Posts: 25
Reputation: Israelsimba is an unknown quantity at this point 
Solved Threads: 0
Israelsimba Israelsimba is offline Offline
Light Poster

Reading from a database

 
0
  #1
Oct 26th, 2009
I have a subscription system that i have developed. the system is supposed to automatically subtract the number of copies given to a client every monthend as per request they made of the copies required upon joining. my problem is i cant make my code run through my database so that it can subtract from every record....instaed it can deal with one record at a time. i cant manually subtract because the records at one time are going to reach thousands. i justa want it to automatically subtract from all fields when a button is clicked.

i have een trying to use this code but its not working.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. With rc
  2. .ActiveConnection = deSub.conn
  3. .LockType = adLockOptimistic
  4. .Source = "select * from cooperatesubs"
  5. .Open
  6. End With
  7. z = rc.Fields("numberofcopies")
  8. Do Until rc.EOF
  9. rc.AddNew
  10. rc.Fields("numberofcopies") = z
  11. rc.Fields("copiesgiven") = y
  12. rc.Fields("copiesremaining") = z - y
  13. rc.Update
  14. rc.MoveNext
  15. Loop
  16. Exit Sub
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 255
Reputation: AndreRet is an unknown quantity at this point 
Solved Threads: 37
AndreRet AndreRet is offline Offline
Posting Whiz in Training
 
0
  #2
Oct 26th, 2009
Try the following -

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. With rc
  2. .ActiveConnection = deSub.conn
  3. .LockType = adLockOptimistic
  4. .Source = "select * from cooperatesubs"
  5. .Open
  6. End With
  7.  
  8. Dim w As Integer
  9. Dim x As Integer
  10. Dim y As Integer
  11. Dim z As Integer
  12.  
  13. Do Until rc.EOF = True
  14.  
  15. y = rc.Fields("copiesgiven")
  16. z = rc.Fields("numberofcopies")
  17. x = z - y
  18. w = y + 1
  19.  
  20. rc.AddNew
  21. 'rc.Fields("numberofcopies") = z This will not change, for it is a set number, correct?
  22. rc.Fields("copiesgiven") = w
  23. rc.Fields("copiesremaining") = x
  24. rc.Update
  25. rc.MoveNext
  26. Loop
  27. Exit Sub
Please mark questions as answered when done.

Be the ONE!!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 25
Reputation: Israelsimba is an unknown quantity at this point 
Solved Threads: 0
Israelsimba Israelsimba is offline Offline
Light Poster
 
0
  #3
31 Days Ago
i strongly believe the problem is with the
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. .movenext
part. its not moving to the next record wich makes it effective on one row only and fails to run through the database.
i was wondering isnt there any other way of doing this besides this one
thanx you
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC