Solved

Access a MS Access DB that have a password

Posted on 2006-07-12
5
177 Views
Last Modified: 2010-04-16
I want to access a database that have a password and the code give me an exception : the file is already open by another user or it's open exclusively. The problem is that the file is not in exclusive mode or open by another user. If I remove the password and set the opening mode to normal, i've got no errors, but if i leave the password, i got the error. Even if I open it witn normal mode.

The code:

String accessConnStr = @"Provider=Microsoft.Jet.OLEDB.4.0;
                                       User Id=admin;Password=Pass;DataSource=C:\DATA.mdb";

try{
        OleDbConnection myConnection = new OleDbConnection(accessConnStr );
        myConnection.open();   // the exception appears when it attempt to connect.
}
...


Can someone help me plz???
0
Comment
Question by:ventrol
5 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 17093039
Try adding this to the connection string:

Jet OLEDB:Database Password=password;

Bob
0
 
LVL 4

Expert Comment

by:DarkXiphoid
ID: 17097569
Check if the database isn't still used by another connection in your application. Always close any connection you opened.

If it still gives the error, you can try to make a new, fresh database and try to connect to that to make sure the problem is in the database and not in your page.

Tell me what happens after you've done this!

Regards,

Robert
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Media Player 2 31
SqlDataBase 7 52
performance tune IIS 10 on win 2016 that only runs one website 4 117
Add different cell to otherwise similiar row 4 45
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question