Solved

VB Connection with Access2000 by ADO & DAO

Posted on 2001-09-04
6
1,116 Views
Last Modified: 2013-11-23
How to connect VB with Access2000 using ADO and DAO ?
Which version of ADO and DAO will support ?
0
Comment
Question by:thangaraj
6 Comments
 
LVL 1

Expert Comment

by:songstre
ID: 6454635
'For DAO
Set oConn = DAO.OpenConnection("C:\MyDocs\MyDB.mdb")

'OR for ADO
Set oConn = CreateObject("ADODB.Connection")
oConn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\Personnal Docs\Novatech.mdb;Persist Security Info=False")
0
 

Expert Comment

by:wvandeneede
ID: 6454648
I have used ADO 2.5 and 2.6 both seem to do the job
just fine.  I think  ADO 2.5 comes standard with Access 2000 (not sure), but you can always download the latest MDAC version from Microsoft for free.  The latest version now is MDAC 2.6.

Anyway the way to connect doesn't really change.
First of all you need a connection object (Let's take ADO).

Go to the Project-References tab and mark the Microsoft ActiveX Data Objects 2.5 Library

Now we can do the coding... (I just took a form with a standard command button on it)

>---- Start Code---<

Option Explicit

Private Sub Command1_Click()

Dim mConnection As ADODB.Connection

Set mConnection = New ADODB.Connection

mConnection.ConnectionString = "Provider=Microsoft.jet.OLEDB.4.0;Data source=" & App.Path & "/Yourdatabase.mdb"

Set mConnection = Nothing

End Sub
>--- End Code---<

The connection string can also contain things like password
other providers to connect to SQL Server etc...

This will connect you to the database, to get data from
the database, you should take a look at the
ADO recordset object which works with the above connection object.
0
 
LVL 1

Expert Comment

by:songstre
ID: 6454676
wvandeneede,

     I can see you are new in EE. Welcome! I'd just like to tell you that in EE, it is considered standard etiquette to post your proposed solution as a comment so that all others may have a chance at answering and you do not lock the question. You should only post as an answer if you are sure that you have the only possible solution to the problem. Thanks.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Expert Comment

by:songstre
ID: 6454679
PS You can withdraw your answer and resubmit it as a comment if you wish.
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 20 total points
ID: 6461359
songstre, if only that were possible. There is currently no withdraw answer option.

thangaraj: you should probably reject this proposed answer at this stage.

Essentially the comments given are correct. To simplify though:

ADO: Requires MDAC_TYP version 2.1 or higher, 2.51 is a stable version, 2.6 is great but doesn't include the jet drivers required for access so probably not your best bet.

DAO: Requires DAO 3.6 rather than DAO 3.51 or lower. This is included with MDAC_TYP upto version 2.51.

You should ensure that the appropriate references are checked in your project and if distributing a project with these components that the correct version of MDAC_TYP is in the \program files\microsoft visual studio\vb98\wizards\pdwizard\redist folder on the development machine.

If you are using ADO with access 2000 then you must use the provider string "Microsoft.Jet.OLEDB.4.0" rather than "Microsoft.Jet.OLEDB.3.51". The version 4 provider will also work with previous versions of access  so you can be assured of some backward compatibility there.
0
 
LVL 2

Expert Comment

by:Lunchy
ID: 6462272
wvandeneede,

I am rejecting your answer on the basis that it does not address the entirety of the questioner's problem.  (Questioner specified DAO and ADO)

Please note that here in the VB topic area the etiquette is to use comments only.  This is one of the busiest areas and even on a simple question there is generally a lot of expert input and activity.  Locking the question by posting as an answer is essentially saying "No-one else has to worry about this, it is so simple it can be answered in a single post."  When many people are posting nearly simultaneously, locking the question leads to confusion and frustration, thus most of us choose to post comments only in order to allow the questioner to choose which comment is the best and to allow the question to remain in the high traffic "Questions awaiting answers" section.

Please read the information at the link below for tips on questions and answers.  If you have any more questions about the way the site works, feel free to post a zero point question at the community support topic area.


Lunchy
Friendly Neighbourhood Community Support Moderator

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

743 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

14 Experts available now in Live!

Get 1:1 Help Now