How do i exeucte a query thats in an access database through VB6?

I have an access database with several querys in and a VB6 program the manipulates access. I want to be be able to add an 'update' button that copys the contects from one access table then pastes it in an empty access table. This table maybe updated so it needs to overwrite what may already be in it.
I have included the main code so far but its the middle bit i havn't got!
Private Sub btnUpdate_Click()
    Dim rA As Integer
    Dim db As New ADODB.Connection
    Dim sSQL As String
    
   
   db.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = \\Server\test Database\testDatabase.mdb"
   db.Open
  
      MsgBox "Completed!!"
   
      db.Close
      Set db = Nothing
End Sub

Open in new window

wilko100Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jpecaCommented:
You can treat Access querry as store procedure

db.Execute "EXEC" & queryname
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
clarkscottCommented:
Private Sub btnUpdate_Click()
    Dim rA As Integer
    Dim db As New ADODB.Connection
    dim rst as adodb.recordset
    Dim sSQL As String


   
   db.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = \\Server\test Database\testDatabase.mdb"
   db.open
      '--- 1st example -----
       sSQL = "Select * from YourTable"
       set rst = db.openrecordset(sSQL)
      if not rst.eof and not rst.bof then
               rst.movefirst
               do while not rst.eof
                         '---- do stuff
                       rst.movenext
               loop
       end if
       rst.close
       set rst = nothing    
 '---- 2nd example ---
    sSQL = "INSERT x into y ......."
    db.execute sSQL
   
      MsgBox "Completed!!"
   
      db.Close
      Set db = Nothing



Scott C
0
wilko100Author Commented:
Sorry been away, thanks you guys sorted it
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.