Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

executing an access query from VB6 app

Posted on 2003-11-03
4
Medium Priority
?
424 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
  • 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 600 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

Technology Partners: 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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

927 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