Results 1 to 2 of 2

Thread: using ADO with password protected MS ACCESS97

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Location
    -
    Posts
    101
    hi! how can u connect ADO with a password protected MS ACCESS97 . i've been using DAO 3.51 with the following code:


    Dim MyWS as Workspace
    Dim MyDB as Database
    Dim MyTable as Recordset

    Set MyWS=DBEngine.Workspaces(0)

    '*** Here's how to open a database with password ***
    Set MyDB=MyWS.OpenDatabase("C:\MyMDB.MDB",False,False, _
    "MS ACCESS;PWD=MyPassword")


    this code works without a problem. but when i use ADO with the following code:


    strconn = "Provider=Microsoft.Jet.OLEDB.3.51;Data" & _
    "Source=C:\MyMDB.MDB;" & _
    "User ID=Admin;Password=MyPassword;"
    Set cnMyCon = New ADODB.Connection
    cnMyCon.Open strconn


    it gave me this error:

    Run-Time Error '-2147467259(80004005)
    Can't start your application. The workgroup information file is missing or opened exclusively by another user.


    there's no one accessing the MyMDB database, therefore it's not exclusively opened and i'm not using any workgroup information file (system.mdw) in my previous codes (using DAO 3.51).

    what am i missing. i'll appreciate any help

    thanks

    rod

    icq: 16228887

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Leavenworth KS USA
    Posts
    482
    This may help.
    Code:
    Function GetJetConnection(strPath As String, lngMode As ADODB.ConnectModeEnum, _
    Optional strDBPwd As String, Optional strSysDBPath As String, _
    Optional strUserID As String, Optional strUserPwd As String _
    Optional lngEngineType As opgJetEngineType) As ADODB.Connection
    Dim cnnDB As ADODB.Connection   
       Set cnnDB = New ADODB.Connection
       With cnnDB
          .Provider = "Microsoft.Jet.OLEDB.4.0"
          .Mode = lngMode
          .Properties("Jet OLEDB:Database Password") = strDBPwd
          .Properties("Jet OLEDDB:System Database") = strSysDBPwd
          .Properties("Jet OLEDDB:Engine Type") = lngEngineType
          .Open ConnectionString:=strPath, UserID:=strUserID, Password:=strUserPwd
       End With
       Set GetJetConnection = cnnDB
    End Function

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