?
Solved

BatchMove Copy

Posted on 1998-06-25
6
Medium Priority
?
450 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
kjteng earned 100 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

770 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