• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

OPEN Encrypted access database using DAO

I am trying open the database password projected encrypted database. I am using below code to open the database. Its not opening. Its giving error messgae.
    Dim db As DAO.Database
    Dim sql As String
    Dim ws As DAO.Workspace
    Dim oconn As String
    Dim recupdate As DAO.Recordset
    Dim recmaster As DAO.Recordset
    Dim recflowmaster As DAO.Recordset
    Set ws = DBEngine.Workspaces(0)
oconn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=C:\bankstaffing\SSP-LCR.mdb;" & _
           "Jet OLEDB:System Database=c:\bankstaffing\secured1.mdw,myUsername, myPassword"
    Set db = ws.OpenDatabase _
    ("C:\bankstaffing\SSP-LCR.mdb", False, False, oconn)
I am getting this error message.
Runtime Error '3151'

ODBC - - connection to  'C:\bankstaffing\SSP-LCR.mdb' failed.
1 Solution
Using DAO, try this:

  Set db = OpenDatabase ("C:\bankstaffing\SSP-LCR.mdb", False, False, ";PWD=myPassword")

Using ADO, try this:

  Dim oConn As New ADODB.Connection
  oConn.Provider = "Microsoft.JET.OLEDB.4.0"
  oConn.Properties("Data Source") = "C:\bankstaffing\SSP-LCR.mdb"
  oConn.Properties("Jet OLEDB:Database Password") = "myPassword"
  oConn.CursorLocation = adUseServer

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now