• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 540
  • Last Modified:

connect .mdb by ADO and ODBC

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.

  • 2
  • 2
1 Solution
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.
victorlongAuthor Commented:
Hi jjbyers,

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

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.
victorlongAuthor Commented:
Adjusted points to 60
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now