Unable to open database. (using Jet/ACE Providers) connection string?

JA12

Member
Joined
Jul 2, 2013
Messages
17
Location
Ireland
Programming Experience
10+
I'm trying to open a 2003 Access Database using OLEDB.

I initially tried:
VB.NET:
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" &
                                   "Data Source=database.mdb;" &
                                   "User ID=;" &
                                   "Password=password;"
which as always worked for me before, but got the error:
VB.NET:
Error Details: 
        Number: 5
        Description: Cannot start your application. The workgroup information file is missing or opened exclusively by another user.
        Source: Microsoft JET Database Engine
        HelpContext: 0
        HelpFile: 
        LastDllError: 183
So I found a system.mdw file on another PC that has Office installed and copied it to "C:\Databases\" and added the line:

VB.NET:
    Dim con As OleDbConnection ' for the Access MDB Connection
    con = New OleDbConnection
    Try
            con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" &
                                   "Data Source=database.mdb;" &
                                   "User ID=;" &
                                   "Password=password;" &
                                   "Jet OLEDB:"System database=C:\Databases\system.mdw;"
This now produces the error:

VB.NET:
Error Details: 
    Number: 5
    Description: Not a valid account name or password.
    Source: Microsoft JET Database Engine
    HelpContext: 0
    HelpFile: 
    LastDllError: 183
I tried using:

VB.NET:
"Jet OLEDB:Database Password=password;"
I get the error:
VB.NET:
Could not find installable ISAM
so that's obviously not right.

I've opened the database with Office and the database opens fine with the password.

I have another application that opens the same files without any problem using the first ConnectionString. This application has the same references as the other project, it has the same Imports, uses the same Class to manage the database access.

I tried using the Provider "Microsoft.ACE.OLEDB.12.0" but that produces exactly the same error.

When I open the database using Office, I get the Security prompt "Enable contents...", I don't know whether this has any bearing on the matter, and if so how to open a database with this security setting.

I don't know where to go from here.

Configuration:
VS2012 Express
VB.NET
Windows 8
.NET Framework 4.5
 
Last edited:
First, you need to confirm the way of the connecting, wether it needs username and password or not,. And from what i see, you don't use any security, so you only need this for the connection string

VB.NET:
[COLOR=#0000BB][FONT=Consolas]Provider[/FONT][/COLOR][COLOR=#2222AA][FONT=Consolas]=[/FONT][/COLOR][COLOR=#222288][FONT=Consolas]Microsoft.ACE.OLEDB.12.0;[/FONT][/COLOR][COLOR=#0000BB][FONT=Consolas]Data Source[/FONT][/COLOR][COLOR=#2222AA][FONT=Consolas]=[/FONT][/COLOR][COLOR=#222288][FONT=Consolas]C:\myFolder\myAccessFile.accdb;[/FONT][/COLOR][COLOR=#0000BB][FONT=Consolas]
Persist Security Info[/FONT][/COLOR][COLOR=#2222AA][FONT=Consolas]=[/FONT][/COLOR][COLOR=#222288][FONT=Consolas]False;


[/FONT][/COLOR]
 
The database has a password but no userid

I've currently trimmed it all down to:
VB.NET:
            con = New ADODB.Connection
            con.Provider = "Microsoft.Jet.OLEDB.4.0"
            con.ConnectionString = "Data Source=database.mdb;" &
                                   "Jet OLEDB:System database=C:\Databases\system.mdw;"
            con.Open(Password:="pswrd")
using ADODB.NET

But I'm still getting:
VB.NET:
 Not a valid account name or password.

Note:
VB.NET:
Persist Security Info=False;
Is SQLServer stuff and not Access.

 
Last edited:
No, that Persist Security Info is not just for SQL,.
So if you have a password, do it like this

VB.NET:
Provider[COLOR=#2222AA][FONT=Consolas]=[/FONT][/COLOR][COLOR=#222288][FONT=Consolas]Microsoft.ACE.OLEDB.12.0;[/FONT][/COLOR][COLOR=#0000BB][FONT=Consolas]Data Source[/FONT][/COLOR][COLOR=#2222AA][FONT=Consolas]=[/FONT][/COLOR][COLOR=#222288][FONT=Consolas]C:\myFolder\myAccessFile.accdb;[/FONT][/COLOR][COLOR=#0000BB][FONT=Consolas]
Jet OLEDB:Database Password[/FONT][/COLOR][COLOR=#2222AA][FONT=Consolas]=[/FONT][/COLOR][COLOR=#222288][FONT=Consolas]MyDbPassword; [/FONT][/COLOR]

And i assume that you already declare that 'con' for a connection, correctly,. And there it goes for the connection string,.
Keep in mind that you need to define the correct provider, and a correct path for your database, and of course the database name and it's extention,
 
Last edited:
VB.NET:
Imports System.IO
Imports ADODB
Public Class clsAccessDB

public function OpenDatabase(byVal pDatabase as string)
        con = New ADODB.Connection
        con.Provider = "Microsoft.ACE.OLEDB.12.0"
        con.Mode = ADODB.ConnectModeEnum.adModeReadWrite
        con.ConnectionString = "Data Source=" & pDatabase & ";" &
                               "Jet OLEDB:System database=C:\Databases\System.mdw;"
        On Error Resume Next
        con.Open(Password:=My.Settings.IRSPassword)
        If Err.Number <> 0 Then
etc.

The
VB.NET:
Jet OLEDB:Database Password=psswd"
doesn't work it throws an ISAM error.
 
VB.NET:
Imports System.IO
Imports ADODB
Public Class clsAccessDB

public function OpenDatabase(byVal pDatabase as string)
        con = New ADODB.Connection
        con.Provider = "Microsoft.ACE.OLEDB.12.0"
        con.Mode = ADODB.ConnectModeEnum.adModeReadWrite
        con.ConnectionString = "Data Source=" & pDatabase & ";" &
                               "Jet OLEDB:System database=C:\Databases\System.mdw;"
        On Error Resume Next
        con.Open(Password:=My.Settings.IRSPassword)
        If Err.Number <> 0 Then
etc.

I think this is where you got it wrong,. "Data Source=" define where your database is, have you declared the value of that & pDatabase & as the path? And you have to define the name of the database itself, it's "myAccessFile.accdb" in the example,. And i don't think you even need "System database=C:\Databases\System.mdw", your first "Error Details" said that you only have to state the right username / password,.
So try to do it like this :

VB.NET:
[FONT=Verdana]      con = New ADODB.Connection
      con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;
[/FONT][FONT=Verdana]      Jet OLEDB:Database Password=MyDbPassword;"[/FONT]        On Error Resume Next
       
      etc.

Replace that C:\myFolder... with your database's path,. And that MyDbPassword with your database's password,.
 
I'm now not sure there was really anything wrong with my code. The application started working as expected after I rebooted for updates.

Go figure!
 
Back
Top