MS ACCess DB openning with password

  • Thread starter Thread starter ablyplus
  • Start date Start date
A

ablyplus

Hi,

I am trying to open MS Access DB with c# like follows...

OleDbConnection thisConnection = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data Source=" +
@"..\..\hren.mdb;" +
@"User Id=Admin;" +
@"Password=xxxxx123"
);
Error description:
Cannot start your application. The workgroup information file is missing or
opened exclusively by another user.

It does not works. Do you know why? I can tell you that db is not opened by
another user.

Thanks in advance
 
Thanks, I appreciate your help, but I unfortunately I still do not
understand how it goes.

Thanks again.
 
Thanks, I appreciate your help, but I unfortunately I still do not
understand how it goes.

OK. Access has two "types" of security: a file password (like Word, Excel
etc) and workgroup security which means that the .mdb file was created under
a secure workgroup.

How would you open this Access database from within Access, not through
C#...?
 
Thanks for answer.

The basic idea is to protect DB and data's from unauthorized access. I have
put password there and now I need to open that within c#.



I have tried to use code showed in previous message. I am not sure what you
exactly mean when saying "How would you open this Access database from
within Access". I am not sure how my data base has created. I have made it
normally within MS Access without any additions.



I would like to give you proper answers but I am not sure how.



Example you send is description of problem what I have, but I am not sure
how I can use it.



Thanks for understanding and help. i beleive you can help me to resolve this
problem. Thanks.
 
Hey there i had the same problems... and i foud a solution.

I have protected my database under access by clicking Tools->Security->Set database password.

Then in c# when i added a new oledbAdapter on my form i made a new connection.

In the DataLink properties dialogbox under the tab All i double clicked Jet OLEDB: Database Password and set my password again there. Then i searched my disk for the file system.mdw and copyed it in /bin/debug or /bin/Release in my project folder. i passed the path by double clicking the Jet OLEDB: System database in the DataLink properties (tab all) dialog box (see text above).
I tested the connection and it worked fine. When initializing your connection (i do that in the constructor method) i added:

string dat = Application.StartupPath+\\MyAccessDatabase.mdw;

string str = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source="+dat+";Jet OLEDB:Database Password=sbvHdpcl; Jet OLEDB:System database="+Application.StartupPath+\\System.mdw;;

myOleDbConnection.ConnectionString = str;

i use the variable dat because my app changes the connection at runtime....

The files MyAccessDatabase.mdb and System.mdw has to be in /bin/debug or /bin/release folded in your project folder.

It works fine for me... i hope i could help u out... and sorry for my english :)

Marko
 
I have tried to use code showed in previous message. I am not sure what
you exactly mean when saying "How would you open this Access database from
within Access". I am not sure how my data base has created. I have made it
normally within MS Access without any additions.

OK - a priori. You say "I have made it normally within MS Access without any
additions". From that, I deduce that you have a copy of MS Access installed
on your PC. When you start MS Access, are you prompted for a workgroup
username and password i.e. are you working within a secure workgroup or are
you using the default (unsecure) workgroup?

Then, when you open this database from within Access (File, Open etc) are
you prompted for a file password?
 
When I start MS Access I am prompted only for password. There is no question
like workgroup...
And yes, my db is installed locally on my desk top.

Thanks
 
THANKS

"Jet OLEDB:Database Password" is key of this problem.

Thanks

Mirko

Hey there i had the same problems... and i foud a solution.

I have protected my database under access by clicking Tools->Security->Set database password.

Then in c# when i added a new oledbAdapter on my form i made a new connection.

In the DataLink properties dialogbox under the tab All i double clicked Jet OLEDB: Database Password and set my password again there. Then i searched my disk for the file system.mdw and copyed it in /bin/debug or /bin/Release in my project folder. i passed the path by double clicking the Jet OLEDB: System database in the DataLink properties (tab all) dialog box (see text above).
I tested the connection and it worked fine. When initializing your connection (i do that in the constructor method) i added:

string dat = Application.StartupPath+\\MyAccessDatabase.mdw;

string str = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source="+dat+";Jet OLEDB:Database Password=sbvHdpcl; Jet OLEDB:System database="+Application.StartupPath+\\System.mdw;;

myOleDbConnection.ConnectionString = str;

i use the variable dat because my app changes the connection at runtime....

The files MyAccessDatabase.mdb and System.mdw has to be in /bin/debug or /bin/release folded in your project folder.

It works fine for me... i hope i could help u out... and sorry for my english :)

Marko
 
Back
Top