jet code fails with password, why ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following function fails if the Jet database has a password. This is the
error:
{"Cannot start your application. The workgroup information file is missing
or opened exclusively by another user." }

However the same Jet database opens easily with VB 6. Thereis no MDW (
workgroup file - never has been. ). So what is happening: ??

public bool testOpenJet( string strDbPath, string pwd)
{
try
{
string sCnnString= "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
System.Data.OleDb.OleDbConnection jetConn = new OleDbConnection();
sCnnString+= sCnnString + strDbPath;
if (pwd.Length>0)
{
sCnnString+= ";Password="+ pwd;
}
jetConn.ConnectionString=sCnnString;
jetConn.Open();
jetConn.Close();
return true;
}
catch ( Exception e)
{
Console.WriteLine(e.Message);
}
return false;
}

VB 6 CODE:
Private Sub Form_Load()
Dim db As DAO.Database
Dim AccessPath As String
Dim dbPassword As String
dbPassword = "test"
AccessPath = "c:\password.mdb"
Set db = OpenDatabase(AccessPath, False, False, ";pwd=" & dbPassword)
End Sub
 
andrewcw said:
The following function fails if the Jet database has a password. This is the
error:
{"Cannot start your application. The workgroup information file is missing
or opened exclusively by another user." }

However the same Jet database opens easily with VB 6. Thereis no MDW (
workgroup file - never has been. ). So what is happening: ??

public bool testOpenJet( string strDbPath, string pwd)
{
try
{
string sCnnString= "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
System.Data.OleDb.OleDbConnection jetConn = new OleDbConnection();
sCnnString+= sCnnString + strDbPath;

There's a bug to start with - your connection string after this
statement will have the "Provider=" bit twice. You either mean

sCnnString = sCnnString + strDbPath;
or
sCnnString += strDbPath;
 
Thanks for the first bug
but when the connection string is coorected and looks like this:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\password.MDB;Password=test"

I still get "Cannot start your application. The workgroup information file
is missing or opened exclusively by another user"

Why ? What else could be wrong ? I dont need a workgroup file for DAO.
 
Precisely there are a lot of sights with incorrect and misleading ideas on
passwords. With JET & oledb you must format the connection string as follows:
http://www.connectionstrings.com/

;Jet OLEDB:Database Password="+ pwd;

SIMPLY Password or pwd simply does not work and brings up misleading errors
 
Back
Top