Running Apped or Update Access Quesry using VisualBasic

I have 2 queries called 'Query_Append' and 'Query_Update' , these are queies made in MS Acces they are of the type APPEND and UPDATE.  How can i run there queries using VisualBasic 6 code?

Thanks,
MICSAsked:
Who is Participating?
 
hmadhurConnect With a Mentor Commented:
Hi
Use the following code to do that. The important thing is that you have to set the Command object's CommandType property to adCmdUnknown. This is the catch.

    Dim objAdoConnection As New ADODB.Connection
    Dim objAdoCommand As New ADODB.Command
   
    objAdoConnection.ConnectionString = "dsn=dsnemp"
    objAdoConnection.Open
   
    objAdoCommand.ActiveConnection = objAdoConnection
    objAdoCommand.CommandType = adCmdUnknown
    objAdoCommand.CommandText = "Query_Append"
    objAdoCommand.Execute

Regards
Madhur
0
 
msrobertsCommented:
Have you connected to the database you want to run the queries on?  

0
 
hmadhurCommented:
Sorry! forgot to mention. You connect by whatever means you want. Either DSN, which I have used, or by using providers.

Madhur
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
MICSAuthor Commented:
Ok. so i tried the example above by hmadhur. and i get the error msg

"Invalid SQL statment; expected 'DELETE','INSERT','PROCEDURE','SELECT', or 'UPDATE'

any ideas?
0
 
MICSAuthor Commented:
Ok. I fond that I was accessing teh wrong database.


0
 
MICSAuthor Commented:
Worked Great
0
All Courses

From novice to tech pro — start learning today.