Solved

executing an access query from VB6 app

Posted on 2003-11-03
4
420 Views
Last Modified: 2010-05-01
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

thanks
0
Comment
Question by:MrKevorkian
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Author Comment

by:MrKevorkian
ID: 9669954
ps the query is in an access 2000 db
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 150 total points
ID: 9669981
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;"
conn.Open()

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

 
For more information about ADO:

http://www.w3schools.com/ado/
http://www.tutorial-web.com/asp/database/
http://www.devguru.com/features/tutorials/ADOandASP/adoTutorial.html 
0
 
LVL 13

Expert Comment

by:VICKRAM
ID: 9670000
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
   ' DO YOUR PROCESSING HERE
Wend

vickram
0
 
LVL 1

Author Comment

by:MrKevorkian
ID: 9670038
both were correct but  Dhaest was first

thanks very much
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question