Solved

BatchMove Copy

Posted on 1998-06-25
6
426 Views
Last Modified: 2010-04-04
I have been trying to do a Table BatchMove and have been encountering several errors.  If I leave the tables open, I receive an error that the tables are open.  If I close the tables the error complains that the process can't be performed on a closed database.  I've tried combinations closing/opening each table with no results.  How do you get this method to work?
0
Comment
Question by:blakec
  • 3
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
kjteng earned 50 total points
ID: 1355924
If you are using batCopy mode you should not set the active property of destination table to true at design time. Otherwise the IDE will reserve write rights to the table.
Somewhere in you code (before calling batchMove1.execute) set the active property of the destination table to true.

eg.
procedure TForm1.Button1Click(Sender: TObject);
begin
  table2.active:= true;
  batchMove1.execute
end;
0
 

Author Comment

by:blakec
ID: 1355925
I was attempting to use the BatchMove function, not the procedure.  Since all my tables are created and destroyed at runtime, it doesn't sound as if the IDE write is an issue.

Can I get the BatchMove function to work in Delphi 1, or do I have to create the BatchMove object?  Is there an advantage of using one over the other, other than the number of lines of code to perform the operation?

function BatchMove(ASource: TDataSet; AMode: TBatchMode): Longint;

0
 
LVL 2

Expert Comment

by:kjteng
ID: 1355926
It seems that some other application have reserve the files. Are you running on network?

table2.batchMove( table1, batCopy) works no matter the table1/table2 is active or not. I have just tested it, it works even if table1 is opened with exclusive right. Let me know if you need my test program for batchMove. I would email it to you.

The advantage of TBatchMove is that you have more control on the batchmove operation. eg you can map the fields of source and target table if each of the two tables have different fieldnames.
(where batchmove method copy the fields data based on field number).
Just drop a tBatchMove component to the form and view the object inspector for more information.

Please post you code if you need further help.
I will only  be back on June 28.





0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:blakec
ID: 1355927
The tables used in this program are used only by this program for single instance runs.  There will probably never be a sharing violation because the program is designed to run on non-networked laptops.

In this instance, the tables need to be a carbon copy of each other because they may need to be used interchangably.  Following is the source code causing the problem.  The program GPF's on the BatchMove call and the error varies depending on whether the source/destination tables are open or closed.

function LoadArchiveTbl: bool;
begin
     LoadArchiveTbl := True;

     with PadMod1, FileLstTbl do
     begin

          Active := True;
          RestoreTbl.Active := True;

          try
          if BatchMove(RestoreTbl, batCopy) <> RecordCount then
          begin
               LoadArchiveTbl := False;
               FailMsg(BAT_COPY_ERR);
          end;
          except on E: exception do
             begin
                  MsgOk2(E.Message);
                  LoadArchiveTbl := False;
             end;
          end;
          {RestoreTbl.Active := True;}
     end;
end;

P.S.  I didn't realize I had a BatchMove component.  This is such a cool programming tool. :) Wish I could convince my Microsoft Office.
0
 
LVL 2

Expert Comment

by:kjteng
ID: 1355928
As the code you post is not complete I have made some assumptions to test it:

1. Assume padMod1, FailMsg, MsgOk2 is irrelevant to the subject.
2. since LoadArchiveTbl is not prefixed with form name, I presume fileLstTbl1 is declared as a global variable. Consequently I have to declare FileLstTbl and restoreTbl as a global variable (type ttable) and created them at runtime.
3. I also write an onclick event to call LoadArchiveTbl

Test result: Everything is working fine.

My second test is the more conventional method: create the tow tables at designtime. have I also modified the LoadArchiveTbl function as follows:

function TForm1.LoadArchiveTbl: bool;
begin
  LoadArchiveTbl := True;
  with {PadMod1,} FileLstTbl do
  begin
    Active := True;
    RestoreTbl.Active := True;
    try
     if BatchMove(RestoreTbl, batCopy) <> RecordCount then begin
       LoadArchiveTbl := False;
      { FailMsg(BAT_COPY_ERR);}
     end;
       except on E: exception do
          begin
{               MsgOk2(E.Message);}
               LoadArchiveTbl := False;
          end;
       end;
       {RestoreTbl.Active := True;}
  end;
end;

This test works fine too.

Please check what I assume above is the same as what you did in your program. If you still cannot get it work, try to create a new test program to see whether the batchMove function works. If the same error still come out on you test program (which is very unlikely), I would advise you to reinstall you delphi.

goodluck
0
 
LVL 3

Expert Comment

by:rickpet
ID: 1355929
I would assume that one of our 2 tables are corrupt...try your test on new tables...I would pick one of the tables from Delphi\Demos\Data

Also make sure that you have enough disk space for the operation.

How large are your tables???

What kinda of tables are we using???


Rick
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now