-
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
-
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 :)
-
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.
-
Try something like this:
Code:
Set db = OpenDatabase("C:\....\database.mdb", False, True, "MS Access;pwd=password")
-
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
-
Check your private messages.
-
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
-
MKSA`s code works a treat and it has the merit of brevity.
Thanks for all support
Regards
Brian F
-
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).