Solved

executing an access query from VB6 app

Posted on 2003-11-03
4
413 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 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now