Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleOpen a password-protected Access database with ADO
DescriptionThis 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.
KeywordsADO, database, data, password, Access
CategoriesDatabase
 
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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated