CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2002
    Posts
    9

    connecting to password protected Access table

    I have created a small table in Access97 and applied a password. I have then put an ADO control onto a form and used the connection builder to create the connection string. Using Jet3.51 Ole DB
    Without the password in Access it connects, but with the password it does not.
    I get an error "Test failed because of an error in initializing provider. Can't start your application. Workgroup information file is missing or exclusively opened by another"
    Can anyone explain what is going on here and how I correct it.


  2. #2
    Join Date
    Mar 2001
    Location
    County Durham, England
    Posts
    238

    Re: connecting to password protected Access table

    Make your COnenction string include the Password option ;

    Provider=Microsoft.Jet.OLEDB.3.51;Data Source='EnterDBPath';Mode=ReadWrite|Share Deny None;Persist Security Info=False;Jet OLEDBatabase Password='EnterPassword'

    Work is necessary for man. Man invented the alarm clock.

  3. #3
    Join Date
    Feb 2002
    Posts
    9

    Re: connecting to password protected Access table

    I agree that should work - but it dosen't
    I get an error password not valid

    strDBuser = App.Path & "\Users.mdb"
    Cn2 = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _
    strDBuser & ";Mode=ReadWrite|Share Deny None;" & _
    "Persist Security Info=false;Jet OLEDBatabase Password='abcd'"

    set wsUser = DBEngine.Workspaces(0)
    'open database
    set DBuser = wsUser.OpenDatabase(strDBuser, , , Cn2)
    'open Users table
    set rsUser = DBuser.OpenRecordset("UserData", dbOpenTable)



    the Access data base is just three columns of data headed Name,Password and Initials
    and I have used the Tools>security>set database password to set the password to abcd (all lower case). Still no joy !


  4. #4
    Join Date
    Mar 2001
    Location
    County Durham, England
    Posts
    238

    Re: connecting to password protected Access table

    Are you putting those single quotes in your Password as shown in your code below ?

    Work is necessary for man. Man invented the alarm clock.

  5. #5
    Join Date
    Feb 2002
    Posts
    9

    Re: connecting to password protected Access table

    I put the single quotes in the connect string
    but no quotes in the database password.
    Note if I leave empty quotes in the connect string and set no database password it does work
    but as soon as I put some characters in it fails


  6. #6
    Join Date
    Mar 2001
    Location
    County Durham, England
    Posts
    238

    Re: connecting to password protected Access table

    I think this is the problem have your tried it without, I have never used Single Quotes round my password and it works fine ?

    Work is necessary for man. Man invented the alarm clock.

  7. #7
    Join Date
    Feb 2002
    Posts
    9

    Re: connecting to password protected Access table

    if I omit the single quotes I get the same result
    Invalid password


  8. #8
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: connecting to password protected Access table

    I think it is a jet matter.
    You should download jet driver from microsoft.com
    (last version is not included in Mdac_typ.exe)


    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  9. #9
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: connecting to password protected Access table

    You are mixing DAO and ADO methods

    it must be:

    strDBuser = App.Path & "\Users.mdb"

    Set cn2 = New ADODB.Connection
    sConn = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _
    strDBuser & ";Mode=ReadWrite|Share Deny None;" & _
    "Persist Security Info=false;Jet OLEDBatabase Password='abcd'"

    cn2.ConnectionString = sConn
    cn2.Open

    'open recordset
    Set rs = New ADODB.Recordset
    sSQL = "select * from YourTable"
    rs.Open sSQL, cn2, adOpenDynamic, adLockOptimistic
    MsgBox "rs is open"

    rs.Close
    Set rs = Nothing
    Set cn2 = Nothing




    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  10. #10
    Join Date
    May 2000
    Location
    Belgium, Bruges
    Posts
    146

    Re: connecting to password protected Access table

    Here is the way to connect to A password protected Access Database:

    Dim cn as new ADODB.Connection
    Dim Rs as new ADODB.Recordset
    cn.Provider = "Microsoft.Jet.OLEDB.3.51"
    cn.Properties("Data source") = "mydatabasepath" 'feg: c:\db1.mdb
    cn.Properties("Jet OLEDBatabase Password") = "mypassword"
    cn.Open
    rs.open "select * from mytable",cn,adopendynamic



    I use this code and it works!!



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

Featured