Solved

BatchMove - Data from Pdox to DBase/ASCII

Posted on 1998-01-24
4
405 Views
Last Modified: 2010-04-04
How can I perform a Batchmove from Paradox table to a DBase or ASCII table?  As you can see in the code below, I run an SQL query, create the Destination Table (DB, DBF or TXT) and try to execute the Batchmove.  I get an error of Invalid Extentsion when either DBF or TXT is choosen.  Is there a 'single' compoenent/piece of code that will fit into my existing code?  Thanks.

try
   with Query1 do begin
      Active := False;
      SQL.Clear;
      sql.add(querystring);
      Open;
    end;
   temptbl := TTable.Create(nil);
   with temptbl do begin
    Active := False;
    DatabaseName := ExtractFilePath(TabNameEdit.text);
    TableName := Extractfilename(TabNameEdit.text);
    case TypeBtn.itemindex of
     1: TableType := ttParadox;
     2: TableType := ttDBase;
     3: TableType := ttASCII;
    end;
   end;
   try
    with BatchMove1 do begin
      Source := Query1;
      Destination := temptbl;
      Execute;
    end;
   finally
    temptbl.Free;
   end;
  finally
    //lst.Free;
  end;
0
Comment
Question by:d4jaj1
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 40 total points
ID: 1357479
This is from Lloyd's help file, shows how to export to a text file.
In the DataBaseName You can write a directory name, say
DataBaseName:='c:\temp';
text tables (ASCII)

Q: How do I make an ASCII text table from a paradox table?
A:
procedure TForm1.Button1Click(Sender: TObject);
var
t1, t2: tTable; {t1 = PW table; t2 = ASCII version}
begin
  t1 := tTable.create(self);
  with t1 do begin
    DataBaseName := 'DBDEMOS';
    tableName := 'customer.db';
    open;
  end;
  t2 := tTable.create(self);
  with t2 do begin
    DataBaseName := 'DBDEMOS';
    tableName := 'myfile.txt';
    TableType := ttASCII;
    CreateTable;
    open;
    edit;
    BatchMove(t1, batCopy);
    close;
  end;
  t1.close;
end;
               { This code came from Lloyd's help file! }
0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1357480
Thanks Ronit,

but can't I move datafrom the Query directly to a TXT or DBF file.  When I run my code above, it works fine when moving the data to a DB file, but raises an exception when trying to move to the others.  Is it necessary to batchmove the query results to a DB file FIRST, then batchmove AGAIN to a TXT or DFB file?
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1357481
try this one, Don't forget to free the objects:

procedure TForm1.Button1Click(Sender: TObject);
var
  t2: tTable;
  t1: tQuery;
begin
  t1 := TQuery.create(self);
  with t1 do begin
    DataBaseName := 'DBDEMOS';
    SQL.Add('select * from customer where              country='+chr(39)+'US'+chr(39));
    open;
  end;
  t2 := tTable.create(self);
  with t2 do begin
    DataBaseName := 'c:\temp';
    tableName := 'myfile.txt';
    TableType := ttASCII;
    CreateTable;
    open;
    edit;
    BatchMove(t1, batCopy);
    close;
  end;
  t1.close;
end;
0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1357482
Thanks,

I had to remove the;
 
 CreateTable;
 open;
 edit;

to get it to work for both DBase & Txt files.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

11 Experts available now in Live!

Get 1:1 Help Now