CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2001
    Location
    White Rock, British Columbia, CANADA
    Posts
    21

    Password Protected Access97 Database and ADO

    Given an Access97 database, Test.MDB, protected with the password Yesca, how would i go about opening it using ADO. I've tried:

    Dim db as new adodb.Connection

    db.Open "Provider=Microsoft.Jet.OLEDB.3.51; Data Source=C:\My Documents\Test.mdb", , "Yesca"




    and i get an error message:
    Run-time error '-2147467259 (80004005)':

    Can't start your application. The workgroup information file is missing or opened exlcusively by another user.


    Now, the database is not opened by any other user or application. So why would i need workgroup information? If i open the database in Acess, i get no mention of this, just a propmt for the password. Any help would be greatly appreciated.



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

    Re: Password Protected Access97 Database and ADO

    Code:
    'connection to secure database
    Dim Cnn As ADODB.Connection
    
    'In the place where you want to establish your connection, such 
    'as the Initialize event of a class module, enter the following:
    
    Dim strConnect As String
    Set Cnn = New ADODB.Connection
    
    'Substitute your own User IDs, Password, Data Source, and System
    'database in the connection string below
        strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Password=MyPassword;User ID=Administrator;" & _
            "Data Source=C:\AccessDBs\DB1.mdb;" & _
            "Persist Security Info=True;" & _
            "Jet OLEDB:System database=C:\AccessDBs\system.mdw"
    
    'if you don't need you can eliminate the last line in connection string
    
    
        With Cnn
            .CursorLocation = adUseClient
            .Open strConnect
        End With
    Iouri Boutchkine
    iouri@hotsheet.com

    [Cimperiali colorized and indented for better reading]
    Last edited by Cimperiali; December 7th, 2002 at 05:36 AM.
    Iouri Boutchkine
    iouri@hotsheet.NOSPAM.com

  3. #3
    Join Date
    Sep 2002
    Posts
    15
    I took the code and couldn't get it to work. What am I missing? Thanks.

  4. #4
    Join Date
    Dec 2002
    Posts
    218
    Try "User ID=Admin;Password=Yesca;"

  5. #5
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125
    Perhaps a review of Access based authorization (users/passwords/rights) is in order...

    User names and passwords are NOT directly stored in the MDB file. The exact technique has varied with different releases of access, but the general concepts is a "workgroup file". This file contains the username,password and a UNIQUE IDENTIFIER. The MDB itself uses the UNIQUE IDENTIFIER to assign the various rights.

    Therefore one can not access a protected MDB file until one has "joined" the correct workgroup.

    If the MDB file was created elsewhere and the assoicated file was not also distributed, then the data is effectively locked beyon all access [ok, there are some well known security breaks for most versions].


    Hope this helps.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  6. #6
    Join Date
    Jun 2001
    Location
    Mi
    Posts
    1,249
    On a related topic ... Is there a way to get access to the workgroup info for a particular database? I would like to use the form/table permissions for editing purposes (i.e. what level of editability does a user have). Any ideas on that front?

    Thanks!

    - Mike

  7. #7
    Join Date
    Sep 2002
    Posts
    15
    Sorry for the double post. I found what I did wrong.

  8. #8
    Join Date
    Dec 2002
    Posts
    3
    Before trying this u should have VB SP 4 installed.

    Dim Cnn As ADODB.Connection


    Dim strConnect As String
    Set Cnn = New ADODB.Connection


    'database in the connection string below
    strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Jet OLEDB: Database Password=YourPassword; " & _
    "Data Source=C:\AccessDBs\DB1.mdb;" & _
    "Persist Security Info=True"



    With Cnn
    .CursorLocation = adUseServer
    .Open strConnect
    End With
    Last edited by Cimperiali; February 2nd, 2004 at 03:22 AM.

  9. #9
    Join Date
    Feb 2003
    Posts
    26
    when I try the code just above I get the fallowing error

    could not find installable ISAM.

    How do I fix this issue?

    Thanks

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

    Jet to be installed

    You have to install jet drivers, which are not included in latest Mdac_typ.exe.
    Make a search at microsoft.com for it herearound:
    http://www.microsoft.com/downloads/r...DisplayLang=en
    Last edited by Cimperiali; February 2nd, 2004 at 03:25 AM.
    ...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.

  11. #11
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104
    ADO is particularly retarded with this respect. I encountered both the errors you post here, neither of which was grounded in tha actual problem.. The installable ISAM was a lie; the connection string was wrong. Also, the "opened by another user" was again, a lie.. the connection string was wrong.

    Eventually, i figured out this connection string:
    Code:
    Private Const DB_PROVIDER = "Microsoft.Jet.OLEDB.4.0;"
    
    ...
    
    strConnect = "Provider=" & DB_PROVIDER & _
          "Data Source=" & DB_PATH & _
          "Jet OLEDB:Database Password=" & DB_PASSWORD
    you see, there is a curious set of parameters to connect to the password protected database, the provider specifies the driver to use, the data source specifies the database file on disk. the database password, however, is NOT the same as the passsword entity of a basic ado connection, and basic password is NOT used to connect to an access97 passworded database.
    Instead, the driver uses the "database password" specifier.. Now, it is written in msdn that any connection time parameters passed to ADO that are not understood, are passed to the driver. That's another lie.. only when you put "Jet OLEDB:" before database password, does it connect properly (forcing pass from ado to the driver itself)

    the conenction string elements must be separated with ;, so your db_path must end in ; and so must the password. the full strConnect will look something like this:

    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\myDB.mdb;Jet OLEDB:Database Password=myPassword;"

    note; this works for me.. your ADO may be retarded again, and not allow it.. i hope it does though
    Last edited by cjard; February 2nd, 2004 at 10:08 AM.
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

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