Solved

HELP : BatchMove operations ??

Posted on 1997-10-12
2
164 Views
Last Modified: 2010-04-03
I am currently using the TBatchMove component within an application I am writing. I have used the following code to try and copy a Table and its indexes into a seperate table under the same directory. I used the batCopy command to copy and it copies the table perfectly but without indexes ?? :(
Can someone help me out the code is shown below :-


  Table1.Active := true ;
  Table2.FieldDefs := Table1.FieldDefs ;
  Table2.IndexDefs.Assign(Table1.IndexDefs) ;
  Table2.CreateTable ;
  Table2.Open ;
  BatchMove1.Execute ;

I checked the directory under DOS and it verifies that the only file made was the .DBF file no .MDX file.
HELP HELP HELP. Can it be done with TBatchmove ??
0
Comment
Question by:westy100697
2 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 70 total points
ID: 1347373
Hi, don't know about the batchmove method but this will work :

DbiCopyTable example

From: "David S. Becker" <dsb@plaza.ds.adp.com>

Here is an example of a routine that I use for copying and deleting tables. It uses DB, DBTables, DbiProcs,DbiErrs, and DbiTypes. You simply provide the directory to copy from, the source table name, the directory to copy to, and the destination table name, and the BDE will copy the entire table, indexes and all to the new file. The delete function takes the path to delete from and the name of the table to delete, the BDE takes care of deleting all associated files (indexes, etc.). These procedures have been pulled off a form of mine, and I've edited them to remove some dependencies that existed with that form. They should now be completely stand-alone. (If they compile, that is! :) Use in good health, and enjoy!

-----------------------------------------------------------------
procedure TConvertForm.CopyTable(FromDir, SrcTblName, ToDir, DestTblName: String);
var
  DBHandle: HDBIDB;
  ResultCode: DBIResult;
  Src, Dest, Err: Array[0..255] of Char;
  SrcTbl, DestTbl: TTable;
begin
  SrcTbl := TTable.Create(Application);
  DestTbl := TTable.Create(Application);
  try
    SrcTbl.DatabaseName := FromDir;
    SrcTbl.TableName := SrcTblName;
    SrcTbl.Open;
    DBHandle := SrcTbl.DBHandle;
    SrcTbl.Close;
    ResultCode := DbiCopyTable(DBHandle,false,
      StrPCopy(Src,FromDir + '\' + SrcTblName),nil,
      StrPCopy(Dest,ToDir + '\' + DestTblName));
    if (ResultCode <> DBIERR_NONE) then
    begin
      DbiGetErrorString(ResultCode,Err);
      raise EDatabaseError.Create('While copying ' +
        FromDir + '\' + SrcTblName + ' to ' +
        ToDir + '\' +   DestTblName + ', the '
        + ' database engine   generated the error '''
        + StrPas(Err) + '''');
    end;
  finally
    SrcTbl.Free;
    DestTbl.Free;
  end;
end;

procedure TConvertForm.DeleteTable(Dir, TblName: String);
var
  DBHandle: HDBIDB;
  ResultCode: DBIResult;
  tbl, Err: Array[0..255] of Char;
  SrcTbl, DestTbl: TTable;
  SrcTbl := TTable.Create(Application);
  try
    SrcTbl.DatabaseName := Dir;
    SrcTbl.TableName := TblName;
    SrcTbl.Open;
    DBHandle := SrcTbl.DBHandle;
    SrcTbl.Close;
    ResultCode := DbiDeleteTable(DBHandle,
      StrPCopy(Tbl,Dir +   '\' + TblName),nil);
    if (ResultCode <> DBIERR_NONE) then
    begin
      DbiGetErrorString(ResultCode,Err);
      raise EDatabaseError.Create('While deleting ' +
        Dir +   '\' + TblName + ', the database ' +
        'engine generated the error '''
        + StrPas(Err) + '''');
    end;
  finally
    SrcTbl.Free;
  end;
end;

Have you used an error check for the TBatchMove? Did it gave you errors?

Have fun,
c.u. ZifNab;
0
 

Author Comment

by:westy100697
ID: 1347374
Thanks very much ZifNab I appreciate the code and here are the points for you.
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

Title # Comments Views Activity
How to fill array with TArray.Create? 14 79
Working with hours 3 46
How to build JSON File in Delphi 6 3 17
DBGrid or StringGrid ? 6 72
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 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

19 Experts available now in Live!

Get 1:1 Help Now