If you are opening a password-protected database, you can use any one of the following three syntaxes: . C# R0 H2 L5 j$ h* a
Dim MyConn As New ADODB.Connection
. @4 a, g5 b0 _' I- B/ h4 s
- ~) S2 W, o- |* T0 w3 h MyConn.Provider = "Microsoft.Jet.OLEDB.4.0"
2 o: f, D" E9 E& {6 O MyConn.Properties("Data Source") = "C:\...\JetPassword.MDB". W* f, }9 z, X6 d; D" Z u
MyConn.Properties("Jet OLEDBatabase Password") = "MyPwd"/ C9 i) m4 n( R. `9 k
MyConn.Open$ u4 y0 M: j* H) j! q
-or- , b% D: I2 A& [9 P2 P- J
Dim MyConn As New ADODB.Connection
+ A! `+ U E5 f% F M* M& e Dim strConn As String
$ v8 w1 m) o7 f0 [
& m7 i' @' \' R, _6 F strConn = "Data Source=C:\...\JetPassword.MDB;" & _
5 F; c' A" O# T6 ^" V1 ` "Jet OLEDBatabase Password=MyPwd"6 i$ @8 r) I2 r# S' `/ x
MyConn.Provider = "Microsoft.Jet.OLEDB.4.0"" t. D9 F) f0 I. r5 C
MyConn.Open strConn/ L3 g0 L" `3 `; N
-or- # O$ i6 G( p8 [) C# [
Dim MyConn As New ADODB.Connection
3 [' J3 R( b7 ]; \# y8 I Dim strConn As String" Q: {4 z I8 m2 l
$ ~* h2 C* r3 e: U9 A strConn = "rovider=Microsoft.Jet.OLEDB.4.0;" & _) A9 a9 q7 b9 \# J3 w+ p" p7 P
"Data Source=C:\...\JetPassword.MDB;" & _
" Y9 K$ |: ~9 f1 a5 x7 d "Jet OLEDBatabase Password=MyPwd"9 Q# g* R7 o+ Z2 a$ i/ |( K
MyConn.Open strConn9 _+ v* n$ o) Y0 o5 G
5 C) e Z3 [* N. z0 x6 p6 K X--------------------------------------------------------------------------------------------------9 H. y+ f5 ?" _# ~
' N% a' i7 M0 A: q
If you are opening a database that uses Jet security, you can use any one of the following three syntaxes: ) e1 a5 {7 z+ m2 R+ J1 N
Dim MyConn As New ADODB.Connection( G w; j( \0 ^1 p3 D
; ?$ e2 L8 N+ Z. q& r
MyConn.Provider = "Microsoft.Jet.OLEDB.4.0"
7 \% n! A, Z [; j8 P8 J MyConn.Properties("Data Source") = "C:\...\JetSecurity.MDB"+ z d5 `! O) d* A9 q. o) b1 H
MyConn.Properties("Jet OLEDB:System database") = "C:\...\System.MDW"
. m# t" j4 n2 J3 ~( g6 ? P MyConn.Open UserID:="Admin", Password:="MyPwd"
5 r8 O p4 Z: } b-or- 0 [- i x1 N0 u' x4 H" N
Dim MyConn As New ADODB.Connection3 A: Q- e6 r! B4 m+ V( s
Dim strConn As String% e7 c$ s' E, Y, v; {
0 ^! G; h' k, C" u& x# F strConn = "Data Source=C:\...\JetSecurity.MDB;" & _. K. t* W9 T( i7 N9 f( u
"Jet OLEDB:System database=C:\...\System.MDW"
# [' {+ Y0 u, {/ z2 i MyConn.Provider = "Microsoft.Jet.OLEDB.4.0"9 d1 L/ h8 P, f& k+ S# N1 B
MyConn.Open ConnectionString:=strConn, _
; ^( @2 W1 U3 N0 | UserID:="Admin", Password:="MyPwd"
6 b# \! }4 p6 t S0 B: E5 R-or- . n% E) T3 q' q0 m5 g9 H
Dim MyConn As New ADODB.Connection
' V- E) ^3 Y7 r3 [2 ~! O Dim strConn As String: J% f2 a% ~+ z% U4 n0 Y3 P
, S8 Z- \% L) N1 `5 n; u strConn = "rovider=Microsoft.Jet.OLEDB.4.0;"" P" E, p% v: w6 z# m
"Data Source=C:\...\JetSecurity.MDB;" & _: y& K3 H6 p- h4 o
"Jet OLEDB:System database=C:\...\System.MDW"( x7 }2 @9 n9 D5 t5 v; B# k
MyConn.Open ConnectionString:=strConn, _
8 h' J; I% I8 E UserID:="Admin", Password:="MyPwd"
. }% [5 V. K7 F R' K( ]7 |; j5 y, I5 G
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.