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

    cant open database

    Im trying to open a database using code
    Set db = OpenDatabase("C:\....\database.mdb", True, ReadOnly, "password") and I get an error message 'insertable ISAM not found'.
    Database opens ok with password removed
    ISAM in help refers to excel but not access which Im using for the db
    Any ideas?
    Regards
    Brian

  2. #2
    Join Date
    Dec 2001
    Location
    India
    Posts
    42
    Yes, infact I too had this error once and observed that it occurs while using providers (dsn less connection) with password protected access databases. If you remove the password the code will work fine with the same mdb.

    To retain the password I had to use a dsn, instead of provider. But the real solution is somewhere with the correct driver, I suppose.


    See this thread also. Might help
    Regards

    Debashish Chakrabarty
    SCJP

    ******************************
    Cool Site for SCJP aspirants at:
    http://www.geocities.com/wahjava
    ******************************

  3. #3
    Join Date
    Sep 2001
    Location
    Montreal Canada
    Posts
    1,080
    From the Office 97 help

    here's the prototype of the function

    set database = workspace.Opendatabase(Name as String,[options],[ReadOnly],[Connect]) as database

    This looks like your connect argument and your options argument are not good.


    The connect argument is expressed in two parts: the database type, followed by a semicolon (;) and the optional arguments. You must first provide the database type, such as "ODBC;" or "FoxPro 2.5;". The optional arguments follow in no particular order, separated by semicolons. One of the parameters may be the password (if one is assigned). For example:

    "FoxPro 2.5; pwd=mypassword"

    Using the NewPassword method on a Database object other than an ODBCDirect database changes the password parameter that appears in the ";pwd=..." part of this argument. You must supply the options and read-only arguments to supply a source string. See the Connect property for syntax.

    To close a database, and thus remove the Database object from the Databases collection, use the Close method on the object.

    Note When you access a Microsoft Jet-connected ODBC data source, you can improve your application's performance by opening a Database object connected to the ODBC data source, rather than by linking individual TableDef objects to specific tables in the ODBC data source.
    Nicolas Bohemier

  4. #4
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090
    Try something like this:
    Code:
    Set db = OpenDatabase("C:\....\database.mdb", False, True, "MS Access;pwd=password")

  5. #5
    Join Date
    Jun 2002
    Posts
    84
    I`m getting the drift of the solution but using
    Set db = OpenDatabase("C:\....\database.mdb", False, True, "MS Access;pwd=password")
    still gives me the error 3170. I`ve picked up on another thread posted by SoniaE which hints that the DLL file might be in the wrong place. Any comments?
    Regards B

  6. #6
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090
    Check your private messages.

  7. #7
    Join Date
    Jun 2002
    Location
    Clane, Ireland
    Posts
    766
    Top open a password protected Access database, you can use the following code: (works for 97 and 2000).

    Code:
         #If Win32 Then
            DBEngine.IniPath = "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Issues"
        #Else
            DBEngine.IniPath = AppIni
        #End If
        
        DBEngine.SystemDB = SysDb
        DBEngine.DefaultPassword = AppPwd 'Set the password for the user about to logon
        DBEngine.DefaultUser = AppUsr 'Set the user id of the user about to logon.
    
    10  Set WS = DBEngine.CreateWorkspace(AppUsr, AppUsr, AppPwd, dbUseJet) 'Create a workspace for this user
        DBEngine.Workspaces.Append WS
    
    20  Set IssuesDB = WS.OpenDatabase(DBName, False, False)
    Hope this helps,

    JP
    JP

    Please remember to rate all postings.

  8. #8
    Join Date
    Jun 2002
    Posts
    84
    MKSA`s code works a treat and it has the merit of brevity.
    Thanks for all support
    Regards
    Brian F

  9. #9
    Join Date
    Jun 2002
    Location
    Clane, Ireland
    Posts
    766
    My code will work if you use a different SYSTEM.MDW than the one in the windows directory. You get the system database by changing the last entry in the

    DBEngine.IniPath = "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Issues

    line i.e. ISSUES (this is the name of my application).
    JP

    Please remember to rate all postings.

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