Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    milton keynes, Buckinghamshire
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    password protection (2003)

    From within excel I have been using the following code to open an access database

    Dim myConnection As ADODB.Connection
    Dim strconxn As String
    strconxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Mod22GetDBDirectoryAndName.Access22GetFileDirector yandName & ";Persist Security Info=False"
    Set myConnection = New ADODB.Connection
    myConnection.Open strconxn
    Dim myRecordset As New ADODB.Recordset
    myRecordset.ActiveConnection = myConnection

    where Mod22GetDBDirectoryAndName.Access22GetFileDirector yandName provides the latest access file name and directory address.

    I now need to protect the database by adding a password. I have tried amending the above code as follows, with no success

    strconxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Mod22GetDBDirectoryAndName.Access22GetFileDirector yandName & ";Persist Security Info=False ;pwd=Password"

    Can you please advise how the code should be amended?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: password protection (2003)

    You shouldn't provide pwd=..., that is meant for databases with user-level security. Keep the old connection string, and specify the database-level password like this.

    ...
    Set myConnection = New ADODB.Connection
    myConnection.Properties("Jet OLEDBatabase Password") = "TopSecret"
    myConnection.Open strconxn
    ...

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    milton keynes, Buckinghamshire
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: password protection (2003)

    Hans

    I have rechecked that everything works fine until I set the password.

    As soon as I set the password on the database and enable the extra row of code, the following results in a 3265 error, stating that the item cannot be found in the collection corresponding to the requested name or ordinal.

    Any suggestions?

    Regards

    Alex

    Dim myConnection As ADODB.Connection
    Dim strconxn As String
    strconxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Mod22GetDBDirectoryAndName.Access22GetFileDirector yandName & ";Persist Security Info=False"
    Set myConnection = New ADODB.Connection
    myConnection.Properties("Jet OLEDBatabase Password") = "Topsecret"
    myConnection.Open strconxn
    Dim myRecordset As New ADODB.Recordset
    myRecordset.ActiveConnection = myConnection

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: password protection (2003)

    Try this:
    <code>
    Dim myConnection As ADODB.Connection
    Dim strconxn As String
    strconxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    Mod22GetDBDirectoryAndName.Access22GetFileDirector yandName & _
    ";Persist Security Info=False;Jet OLEDBatabase Password=TopSecret;"
    Set myConnection = New ADODB.Connection
    myConnection.Open strconxn
    </code>
    or
    <code>
    Dim myConnection As ADODB.Connection
    Dim strconxn As String
    strconxn = "Data Source=" & _
    Mod22GetDBDirectoryAndName.Access22GetFileDirector yandName & _
    ";Persist Security Info=False;"
    Set myConnection = New ADODB.Connection
    myConnection.Provider = "Microsoft.Jet.OLEDB.4.0"
    myConnection.Properties("Jet OLEDBatabase Password") = "TopSecret"
    myConnection.Open strconxn</code>

Posting Permissions

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