Results 1 to 3 of 3

Thread: database password

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 1999
    Posts
    12

    Question

    How do I open an access database with a password on it from VB? The DB doesn't have user-level security...just a database password.....
    Thanks

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Leavenworth KS USA
    Posts
    482

    Smile

    To open a password-protected Access database using ADO, specify the password with the provider-specific Jet OLEDBatabase Password property by using the Properties collection of the Connection object, or as part of the connection string passed to the Open method of the Connection object. This is the basic MSDN example:

    Function OpenProtectedDB(strDBPath As String, strPwd As String)
    Dim cnnDB As ADODB.Connection
    Set cnnDB = New ADODB.Connection
    ' Open database for shared, read/write access, and
    ' specify database password.
    With cnnDB
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .Properties("Jet OLEDBatabase Password") = strPwd
    .Mode = adModeReadWrite
    .Open strDBPath
    End With
    ' Play with database code goes here...
    cnnDB.Close
    Set cnnDB = Nothing
    End Function

    FWIW, the OpenProtectedDB proc is available in the modSecurity module in AccessSecurity.mdb in the ODETools\V9\Samples\ODETools\V9\Samples\OPG\Samples\CH18 subfolder on the Office 2000 Developer CD-ROM. Cheers.


  3. #3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width