Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

BatchMove - Data from Pdox to DBase/ASCII

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

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

648 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