App *thinks* table is opened by another app... 
Author Message
 App *thinks* table is opened by another app...

Below is code I'm trying to use to copy a dbf file.  Even though I expressly
make the table inactive, I still get the error that the file is in use by
another application.  Form1 is the only form with a TTable component, Form2 is
only used for input from user for subdirectory name.

I *must* be missing something obvious....

Thanks in advance for all suggestions,
Stuart Kohler

----------------------------------

procedure TForm1.Button2Click(Sender: TObject);
begin
  Form2.ShowModal;
  Label1.Caption := '';

  if Form2.Edit1.Text <> '' then
    begin
      {Check to see if subdirectory exists}
      if DirectoryExists(Form2.Edit1.Text) then
        begin
        Label1.Visible := true;
        Label1.Caption := 'Subdirectory ' + Form2.Edit1.Text + ' already
exists!'
        {Copy files only after warning?}
        end
      else
        Mkdir(Form2.Edit1.Text);
          {Copy files}
        WhichFile := 'quickbib.dbf';
        DestFile := Form2.Edit1.Text + '\' + WhichFile;
        FileCopy(WhichFile,DestFile);
      end;

  Form2.Edit1.Text := '';
end;

procedure TForm1.FileCopy(const FromFile, ToFile: string);
var
  FromF, ToF: file;
  NumRead, NumWritten: Word;
  Buf: array[1..2048] of Char;

begin
 With QuickBib do
   begin

     QuickBib.Active := false;

     AssignFile(FromF, WhichFile);
     ReSet(FromF); {Record Size = 1}
     AssignFile(ToF, DestFile);
     Rewrite(ToF, 1);
     repeat
       BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
       BlockWrite(ToF, Buf, NumRead, NumWritten);
     until (NumRead = 0) or (NumWritten <> NumRead);

     CloseFile(FromF);
     CloseFile(ToF);

     QuickBib.Active := true;

     end;
end;



Sun, 25 Mar 2001 03:00:00 GMT  
 App *thinks* table is opened by another app...
Stuart,

My guess is that you have the TTable component open in design mode, and
that you're attempting to run the program from within the Delphi IDE. If
I'm correct then, since Delphi already has the table open your executing
program is unable to open it.

Regards,

Bill



Quote:

> Below is code I'm trying to use to copy a dbf file.  Even though I
expressly
> make the table inactive, I still get the error that the file is in use by
> another application.  ...



Sun, 25 Mar 2001 03:00:00 GMT  
 App *thinks* table is opened by another app...

Ah, talk about shooting myself in the foot....

The answer lies in two mistakes, of my own doing.  First, I deactivated the
table in the called procedure, not the calling procedure and second, more
importantly, I coded in changing the database path in the OnFormCreate to make
sure the app pointed to the database files in the same directory as the app.
The development directory was holding open the dbf file.

Sorry for the bogus posting!
Stuart Kohler,



Sun, 25 Mar 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. opening a file that is already open in another app

2. TechTips: A different way of thinking about database apps

3. Creating Win 3.1 apps/network apps in win 95

4. How to build an app (with bde) that runs with other bde-apps

5. share a paradox file between a delphi app and another app

6. client - server apps and intranet apps

7. DB App - Too many open cursors

8. TDatabase.Open causes probs for other apps...

9. TechTips: Designing safer apps using local tables

10. Slow Paradox 7 tables on network app.

11. Multiuser App using Paradox Tables

12. Distributing Apps that use dbase tables and BDE

 

 
Powered by phpBB® Forum Software