?
Solved

BatchMove - Data from Pdox to DBase/ASCII

Posted on 1998-01-24
4
Medium Priority
?
438 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 160 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

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

764 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