Hello Friends,

I have compeleted my project but I just need one help....

I want that when the application exe file is running at that time the database associated with the application shud be closed....

Means...I am using the .mdb file...

is there any way that when the application starts, if the user has opened the .mdb file then it shud be closed and also that when the application is running no one shpuld be able to open the .mdb file....

Please just let me know if its possible...

Thanks in advance

hello!
i think it is not possible in mssql server , you can open it even when your software is running . this is what i think , so dont lose hope , if you find any solution please post it here for others .

Regards

If this is a single user application then the database should not be open when the application starts. I'm going to assume, then, that this is a network available database that is available to more than one user. I presume that by

when the application is running no one should be able to open the .mdb file

you mean that no one else should be able to open it. Is that correct? If so, then you should create an "in_use" table that contains only one record - the name or other ID of the person who currently has the database open. If anyone else runs the app, it can check the in_use table and display a message, possibly identifying the person who currently has the database open.

if the user has opened the .mdb file then it shud be closed and also that when the application is running no one shpuld be able to open the .mdb file....

Open by what??

Your application or 3rd Party app??

You can connect exclusively to an Access db (I assume from the .mdb that this is access prior to 2007) by using this connection string:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Mode=Share Exclusive;User Id=admin;Password=;

as specified by www.connectionstrings.com (look up connection string for access 2007 if that's the correct version here).

If you try to connect to an access db exclusively when it's in use you'll get an error. If you have an access open exclusively and somebody else tries to connect to it then they will get an error.

hello!
i think it is not possible in mssql server , you can open it even when your software is running . this is what i think , so dont lose hope , if you find any solution please post it here for others .

Regards

it is for *.mdb file....
Microsoft Access

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.