Solved

BatchMove - Data from Pdox to DBase/ASCII

Posted on 1998-01-24
4
428 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
[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
  • 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

Industry Leaders: 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!

Question has a verified solution.

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

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…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 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