VB Connection with Access2000 by ADO & DAO

How to connect VB with Access2000 using ADO and DAO ?
Which version of ADO and DAO will support ?
thangarajAsked:
Who is Participating?
 
TimCotteeConnect With a Mentor Head of Software ServicesCommented:
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
 
songstreCommented:
'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
 
wvandeneedeCommented:
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
songstreCommented:
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
 
songstreCommented:
PS You can withdraw your answer and resubmit it as a comment if you wish.
0
 
LunchyCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.