‘Sample visual basic code on how to open a password protected access database using ADO object
Option Explicit
Dim Conn As New ADODB.Connection, ConStr As
String
String
Private Sub Btn_OpenDB_Method1()
‘Open the connection
‘Open the connection
Conn.Open “Provider=Microsoft Jet 4.0 OLE DB Provider;Data Source=” & App.Path & “Data1.mdb” & _
“;Jet ” & “OLEDB:Database Password=123456″
MsgBox “Data File is now opened”
Conn.Close
End Sub
Private Sub Btn_OpenDB_Method2()
ConStr = “Data Source=” & App.Path & “Data1.mdb”
Conn.Provider = “Microsoft Jet 4.0 OLE DB Provider”
Conn.ConnectionString = ConStr
Conn.Properties(“Jet OLEDB:Database Password”) = “123456″
Conn.Open
MsgBox “Data File is now opened”
Conn.Close
End Sub
No comments:
Post a Comment