Microsoft KB Archive/191754

= How to open a secured Access database in ADO through OLE DB =

Article ID: 191754

Article Last Modified on 7/10/2006

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.1 Service Pack 2
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft OLE DB Provider for Jet 1.0

-



This article was previously published under Q191754



SUMMARY
The native OLE DB provider for Microsoft Access databases that ships with Microsoft Data Access Components (MDAC) version 2.0 or later enables you to open a secured Microsoft Access database.



MORE INFORMATION
If you are opening a password-protected database, you can use any one of the following three syntaxes: Dim MyConn As New ADODB.Connection

MyConn.Provider = "Microsoft.Jet.OLEDB.4.0" MyConn.Properties("Data Source") = "C:\...\JetPassword.MDB" MyConn.Properties("Jet OLEDB:Database Password") = "MyPwd" MyConn.Open

-or-

Dim MyConn As New ADODB.Connection Dim strConn As String

strConn = "Data Source=C:\...\JetPassword.MDB;" & _ "Jet OLEDB:Database Password=MyPwd" MyConn.Provider = "Microsoft.Jet.OLEDB.4.0" MyConn.Open strConn

-or-

Dim MyConn As New ADODB.Connection Dim strConn As String

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\...\JetPassword.MDB;" & _ "Jet OLEDB:Database Password=MyPwd" MyConn.Open strConn

If you are opening a database that uses Jet security, you can use any one of the following three syntaxes: Dim MyConn As New ADODB.Connection

MyConn.Provider = "Microsoft.Jet.OLEDB.4.0" MyConn.Properties("Data Source") = "C:\...\JetSecurity.MDB" MyConn.Properties("Jet OLEDB:System database") = "C:\...\System.MDW" MyConn.Open UserID:="Admin", Password:="MyPwd"

-or-

Dim MyConn As New ADODB.Connection Dim strConn As String

strConn = "Data Source=C:\...\JetSecurity.MDB;" & _ "Jet OLEDB:System database=C:\...\System.MDW" MyConn.Provider = "Microsoft.Jet.OLEDB.4.0" MyConn.Open ConnectionString:=strConn, _ UserID:="Admin", Password:="MyPwd"

-or-

Dim MyConn As New ADODB.Connection Dim strConn As String

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" "Data Source=C:\...\JetSecurity.MDB;" & _ "Jet OLEDB:System database=C:\...\System.MDW" MyConn.Open ConnectionString:=strConn, _ UserID:="Admin", Password:="MyPwd" NOTE: Jet 3.51 OLEDB provider is designed to open Access 97 databases only. Jet 4.0 OLEDB provider is designed to open Access 2000 or Access 97 databases.

If you must use the Jet 3.51 Provider in the above examples, change the provider name to "Microsoft.Jet.OLEDB.3.51."

We recommend that you take additional steps to incorporate encryption on the network. For example, you can use the Secure Sockets Layer (SSL) when you run the application on a network.

Microsoft Data Access Components (MDAC) version 2.6 and later do not contain the following Jet components:

Keywords: kbhowto kbjet kbmdacnosweep KB191754

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.