CodeItBetter Programming Another VB Programming Blog

How to Open a password-protected Access database with ADO

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'Database - How to Open a password-protected Access database with ADO
'The program sets the ConnectionString's "Jet OLEDB:Database Password" field to 
'the password value.

Private Sub cmdOpen_Click()
    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
 
    ' Open the connection.
    Set conn = New ADODB.Connection
    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & _
        Me.txtDbName.Text & ";" & "Jet OLEDB:Database Password=" & txtPassword.Text
    conn.Open
 
    ' Get the data.
    Set rs = conn.Execute("SELECT Title FROM Books ORDER BY " & "Title")
    lstTitles.Clear
    Do While Not rs.EOF
        lstTitles.AddItem rs!Title
        rs.MoveNext
    Loop
 
    rs.Close
    conn.Close
End Sub
Filed under: Database Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.