Error when trying to connect to pass protected db
Hi all,
I'm tring to connect to a password protected microsoft access mdb file and I get an error about the data base being opend exclusevly by another user. The thing is that the db is on my disk and is not opened.
The connection string is like this:
Code:
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" +
"User Id=admin;Password=xxx;Jet OLEDB:Engine Type=5;Persist Security Info=True;" +
"Data Source=C:\\Documents and Settings\\Mihai\\Desktop\\Imobiliare\\Vita\\BD\\anunturi.mdb");
The thing is that if I try to open a mdb file that has no password and I remove the part about User Id and Password from the conn string it works.
Can someone help me out?
Thank you!
Re: Error when trying to connect to pass protected db
Quote:
OLE DB, OleDbConnection (.NET)
1.Standard security:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password=;"
2.With password:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB: Database Password=MyDbPassword;"
3.Workgroup (system database):
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:System Database=system.mdw;"
Try something like this if you have a password set for the database , not user password:
Code:
OleDbConnection aConnection = newOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C:\\Documents and Settings\\Mihai\\Desktop\\Imobiliare\\Vita\\BD\\anunturi.mdb;" +
"Jet OLEDB:Database Password=123;");
aConnection.Open();
aConnection.Close();
Please post your exception.
Re: Error when trying to connect to pass protected db
I tried that but is not working. I'm getting the same error. I now renounced OleDB and I'm using ODBC. Seems like it's working this way.
Thank you!
Re: Error when trying to connect to pass protected db
You probably got this error :
Quote:
A first chance exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: Cannot start your application. The workgroup information file is missing or opened exclusively by another user.
I think you need to have an ordinary file .mdw that stores the users .
Note that the code with DataBase password works only if you have a database password ( which is different from a normal user/password).
You can create a mdw file with Ms Access wizard ( Tool - Security - User Level Security Wizard) . This will generate a Security.mdw where the users you insert (with password) are kept.
Then you can use it like this :
Code:
aConnection = newOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\music.mdb;Jet OLEDB:System database=C:\\Security.mdw;User Id=gigi;Password=123;");
I tried this code an works fine.
Re: Error when trying to connect to pass protected db
I heard something about this mdw database so I lookd on my system drive and found a System.mdw. Tried with that one and still didn't work. I didn't know that you can create a mdw file. Anyway is not a good ideea with this mdw beacause I'm distributing this application and I don't want to have another file to take care about. For now ODBC is working so I'm leaving it this way!
Thanks!