How To Open a Secured Access Database in ADO Through OLE DB (Q191754)

The information in this article applies to: 'Microsoft Visual Basic Professional Edition for Windows, versions 5.0 , 6.0 'Microsoft Visual Basic Enterprise Edition for Windows, versions 5.0 , 6.0 'ActiveX Data Objects (ADO), versions 2.0 , 2.1 SP2 , 2.5 'Microsoft OLE DB Provider for Jet, version 1.0 '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."

'Starting with Microsoft Data Access Components (MDAC) version 2.6,
'MDAC no longer contains the following Jet components:

'- Microsoft Jet
'- Microsoft Jet OLE DB Provider
'- ODBC Desktop Database Drivers

'For additional information, click the article number below to view
'the article in the Microsoft Knowledge Base:
'Q239114 ACC2000: Updated Version of Microsoft Jet 4.0 Available in
'Download Center
'The "MDAC 2.5 Stack and Windows File Protection" white paper
'contains a full list of the components that are shipped with MDAC
'2.5, along with a discussion of Windows File Protection. Refer to
'this white paper for more information about the Jet dynamic-link
'libraries (DLLs) that are included in MDAC 2.5, which are no longer
'a part of MDAC 2.6.

'For more information about MDAC 2.5 and Windows File Protection, see
'the following Microsoft Web site:
'http://www.microsoft.com/data/mdacwfp.htm

Sumber: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q191754 1

No comments: