Solved

BatchMove - Data from Pdox to DBase/ASCII

Posted on 1998-01-24
4
422 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reconfigure Delphi Install? 2 52
Convert a string into a TDateTime 5 61
how can i search if string exist in array ? 3 59
Firemonkey DbLookupComboBox equivalent ? 2 49
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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