Solved

HELP : BatchMove operations ??

Posted on 1997-10-12
2
185 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
[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
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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month7 days, 7 hours left to enroll

632 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