Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Programmatically removing the dbisam.lck file
Wed, Mar 27 2013 12:38 PMPermanent Link

Mark Shapiro

Is there any way to release DBISAM's hold on the dbisam.lck file so that it can be deleted programmatically at run time other than by setting Engine.Active := false and then Engine.Active := true? This requires a re-entry of passwords for encrypted tables which I'd prefer not to do.

Mark Shapiro
Wed, Mar 27 2013 12:53 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< Is there any way to release DBISAM's hold on the dbisam.lck file so that
it can be deleted programmatically at run time other than by setting
Engine.Active := false and then Engine.Active := true? This requires a
re-entry of passwords for encrypted tables which I'd prefer not to do. >>

As long as you close all open databases, you should be able to delete it.
Just call this method of the TDBISAMSession to make sure that any
non-explicit databases are closed:

http://www.elevatesoft.com/manual?action=viewmethod&id=dbisam4&product=delphi&version=7&comp=TDBISAMSession&method=DropConnections

If you have any other questions, please let me know.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Mar 28 2013 10:24 AMPermanent Link

Mark Shapiro

Tim,

Here is my code with your suggestion:

   if FileExists(CurDir + 'tables\dbisam.lck') then
   begin
     DBISAMSession1.DropConnections;
     DeleteFile(CurDir + 'tables\dbisam.lck');
   end;

I've also tried it by first setting DBISAMSession1.Active := false. In either case, DeleteFile returns false.

Mark Shapiro
Thu, Mar 28 2013 10:50 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Mark

Reading the link Tim provided I'd say that doesn't close the normal tables so you'd need something like

   if FileExists(CurDir + 'tables\dbisam.lck') then
   begin
     DBISAMSession1.DropConnections;
     DBISAMSession1.Close;
     DeleteFile(CurDir + 'tables\dbisam.lck');
   end;

If that doesn't work then I'd download one of the unlock utilities to see just what is holding the file.

Roy



Thu, Mar 28 2013 12:34 PMPermanent Link

Mark Shapiro

Roy & Tim,

Unfortunately, that did not work. Enclosed is the dbisam.lck file I'm trying to delete.

Mark Shapiro



Attachments: dbisam.lck
Fri, Mar 29 2013 5:34 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Mark


Probably a silly question but there is only one instance of the app running isn't there?

Roy Lambert [Team Elevate]
Fri, Mar 29 2013 7:36 AMPermanent Link

Mark Shapiro

Roy,

>Probably a silly question but there is only one instance of the app running isn't there?

Not silly, but yes, there is only one instance.

Mark Shapiro
Fri, Mar 29 2013 1:03 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< I've also tried it by first setting DBISAMSession1.Active := false. In
either case, DeleteFile returns false. >>

You can use the Windows unit's GetLastError function to get the last error
code after a DeleteFile call fails under Windows.  Add that to your code and
let me know what the error code is.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com

Tue, Apr 2 2013 9:34 AMPermanent Link

Mark Shapiro

Tim,

GetLastError returns a 32 -"The process cannot access the file because it is being used by another process." So now I have to figure out what that other process is.

Mark Shapiro

Tue, Apr 2 2013 12:25 PMPermanent Link

Mark Shapiro

Tim,

Great relief at this end. There was a threading event I'd completely overlooked that occurred before the code to delete the dbisam.lck file. When I moved it to a trailing position, the file was successfully deleted. Thanks for your help.

Mark Shapiro

Image