executing an access query from VB6 app

i want to connect to an access db then execute one of its querys.

I want to do this from a seperate vb6 application.

some code would be great

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

MrKevorkianAuthor Commented:
ps the query is in an access 2000 db
Dirk HaestProject managerCommented:
1) make sure that you have the libraries included in your project

under vb6 go to tools -> reference -> add ms ado 2.5 (or higher) and ms vb for applications extensibility

2) create the database object and recordset object

Dim conn As New ADODB.Connection
Dim rcd As New ADODB.Recordset

3) open the connection

conn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=D:\path\file.mdb;"

4) execute the query
rcd.execute ("YourQueryName")

For more information about ADO:


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
here it is
make a reference to ActiveX Data Objects Library..i used ADO 2.1

Dim adoCon As New ADODB.Connection
Dim adoCom As New ADODB.Command
Dim adoRs As ADODB.Recordset
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data.mdb;Persist Security Info=False"

adoCom.CommandType = adCmdStoredProc
adoCom.CommandText = "qryQueryName"
adoCom.ActiveConnection = adoCon
Set adoRs = adoCom.Execute()

While Not adoRs.Eof

MrKevorkianAuthor Commented:
both were correct but  Dhaest was first

thanks very much
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.