connect .mdb by ADO and ODBC

Posted on 1999-01-07
Last Modified: 2013-11-23
I want to try ODBC and ADO.

Can you give me a step by step instruction showing how to connect a mdb file? (from get a refrence, if any, to create a recordset)

Thank you in advance.

Question by:victorlong
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
  • 2

Accepted Solution

jjbyers earned 60 total points
ID: 1454602
Make sure you select Microsoft ActiveX Data Objects 2.0 Library from the References item under the Projects menu.

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

  Set cn = New ADODB.Connection
  Set rs = New ADODB.Recordset
  cn.CursorLocation = adUseClient
  rs.CursorLocation = adUseClient
  cn.Provider = "Microsoft.Jet.OLEDB.3.51"
  cn.Open "C:\program files\devstudio\vb\nwind.mdb", "admin", ""
  rs.Open "Select * from customers", cn, adOpenStatic, adLockBatchOptimistic
  Set MSHFlexGrid1.Recordset = rs
  Set rs = Nothing
  Set cn = Nothing

Hope this helps.

Author Comment

ID: 1454603
Hi jjbyers,

Can you tell me the file name for Microsoft ActiveX Data Objects 2.0? I just can not find it :-(


Expert Comment

ID: 1454604
You might have to install ADO on your box to see it under the References dialog box, under the Projects menu.

The name of the file is MSADO15.DLL.

On my box it's installed under c:\program files\common files\system\ado.

Author Comment

ID: 1454605
Adjusted points to 60

Featured Post

Industry Leaders: 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 While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

691 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