OPEN Encrypted access database using DAO

Posted on 2004-11-16
Last Modified: 2013-12-25
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.
Question by:tomjones735
    1 Comment
    LVL 12

    Accepted 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

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now