Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2006

Tip: Looking for answers? Try searching our database.

How to 'lock' a file?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nvx - 29 Jun 2006 14:16 GMT
Hi,
I have an application working with an Access database and I need to
'lock' the currently opened DB file in order to prevent it to be
deleted, modified by other applications etc. Does anyone know how to
achieve this? An information regarding unlocking a file would also be
appreciated.

Thanks for any help...

Regards
nvx
Mehdi - 29 Jun 2006 15:10 GMT
> Hi,
> I have an application working with an Access database and I need to
> 'lock' the currently opened DB file in order to prevent it to be
> deleted, modified by other applications etc. Does anyone know how to
> achieve this? An information regarding unlocking a file would also be
> appreciated.

Usually, methods that allow you to open a file provide you with the option
of passing a FileShare argument letting you specify whether or not you want
to allow other processes to have read or write access to your file while
you have it open. Have a look at the doc for FileShare. The File.Open()
method for example accept a FileShare argument. If you choose not to let
other processes have access to your file while you are having it open, you
can remove this "lock" simply by closing the file.

I'm not sure what happens in the particular case of an Access file. I seem
to remember from the time we were using Access for our database that you
can specify in the connection string what type of file sharing you want.
nvx - 30 Jun 2006 08:43 GMT
Thank you very much for your time. I briefly checked the DB file
properties in my VC# Express Edition and found nothing similar. It is
probably caused by the version of VS, but I'm not sure. I'll try to
google this 'FileShare' thing to find out more...

Regards
nvx

Mehdi napsal:

> > Hi,
> > I have an application working with an Access database and I need to
[quoted text clipped - 14 lines]
> to remember from the time we were using Access for our database that you
> can specify in the connection string what type of file sharing you want.
MarkTheNuke - 30 Jun 2006 10:33 GMT
Hello nvx,
I did a quick google and found that you can specify Exclusive in the
connection string.
http://www.google.com/search?hl=en&q=.NET+Access+Connection+String
Good Luck,
Mark

> Thank you very much for your time. I briefly checked the DB file
> properties in my VC# Express Edition and found nothing similar. It is
[quoted text clipped - 24 lines]
> > to remember from the time we were using Access for our database that you
> > can specify in the connection string what type of file sharing you want.
nvx - 30 Jun 2006 17:30 GMT
Thank you very much... :) That seems to be the exact thing I need... I
really appreciate your effort. Since I'm a newbie I don't know the
proper keywords to search for.

Regards
nvx

MarkTheNuke napsal:
> Hello nvx,
> I did a quick google and found that you can specify Exclusive in the
[quoted text clipped - 31 lines]
> > > to remember from the time we were using Access for our database that you
> > > can specify in the connection string what type of file sharing you want.
nvx - 30 Jun 2006 17:36 GMT
Thank you very much... :) That seems to be the exact thing I need... I
really appreciate your effort. Since I'm a newbie I don't know the
proper keywords to search for.

Regards
nvx

MarkTheNuke napsal:
> Hello nvx,
> I did a quick google and found that you can specify Exclusive in the
[quoted text clipped - 31 lines]
> > > to remember from the time we were using Access for our database that you
> > > can specify in the connection string what type of file sharing you want.
nvx - 30 Jun 2006 17:36 GMT
Thank you very much... :) That seems to be the exact thing I need... I
really appreciate your effort. Since I'm a newbie I don't know the
proper keywords to search for.

Regards
nvx

MarkTheNuke napsal:
> Hello nvx,
> I did a quick google and found that you can specify Exclusive in the
[quoted text clipped - 31 lines]
> > > to remember from the time we were using Access for our database that you
> > > can specify in the connection string what type of file sharing you want.
nvx - 30 Jun 2006 20:36 GMT
Uh... I guess something went wrong here... :)

nvx napsal:
> Thank you very much... :) That seems to be the exact thing I need... I
> really appreciate your effort. Since I'm a newbie I don't know the
[quoted text clipped - 39 lines]
> > > > to remember from the time we were using Access for our database that you
> > > > can specify in the connection string what type of file sharing you want.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.