Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

executing an access query from VB6 app

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

Independent Software Vendors: 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

670 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