|
|
Title | Open a password-protected Access database with ADO |
Description | This example shows how to open a password-protected Access database with ADO in Visual Basic 6. It sets the ConnectionString's "Jet OLEDB:Database Password" field to the password. |
Keywords | ADO, database, data, password, Access |
Categories | Database |
|
|
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
|
|
|
|
|
|