Solved

Managing *.dbf tables

Posted on 2001-07-25
3
149 Views
Last Modified: 2012-05-04
Hi guys,

Can you help me with this?
I have a fragment of code that does the following:

It takes the data from Table1 and Table2 and joins it using a sql statement (select a.*,b.* from Table1 a, Table2 b where a.fieldname=b.fieldname) and puts it in a 3rd Table called c.dbf. But the Buttonclick procedure allows only 1 row of data (1 record). What I need is making possible that rows could be appended to c.dbf as data in Table2 changes (or gets appended).
Here's the code:

procedure TForm1.FormCreate(Sender: TObject);
begin
DBEdit9.Text := FormatDateTime('dd.mm.yyyy',Now);
FMXUtils.CopyFile('c:\windows\desktop\zbnalgl0.dbf','c:\windows\desktop\temp\');
RenameFile('c:\windows\desktop\temp\zbnalgl0.dbf', 'c:\windows\desktop\zbnalgl.dbf');
Table2.TableName:= 'zbnalgl.dbf';
Table2.Active:=True;
//

//
end;

procedure TForm1.Button1Click(Sender: TObject);
var t:ttable;
begin
Table2.Post;
Table2.Close;
//moe
Table1.Open;
Table2.Open;
//od EE
//
Table2.Edit;
DBEdit9.Text:=DateToStr(Date);
//Table2.Post;    //
t := ttable.create(nil);
try
  query1.open; //this query contains the sql-statement
  t.databasename := query1.databasename;
  t.tablename := 'c.dbf';
  t.batchmove(query1,BatCopy); //this will create the table and insert the records from table1
finally
 query1.close;
  t.free;  //release object instance
end;
//moe
Table2.Close;
//moe2
end;

Thanks, Blash
0
Comment
Question by:blash
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 6317080
if c.dbf already exists,
then use
t.batchmove(query1,BatAppend);
or
t.batchmove(query1,BatUpdateAppend); //??is the name relly so

meikl ;-)
0
 

Author Comment

by:blash
ID: 6320917
Such a long question, so short the answer!

Thanks meikl :)))
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6320988
:-) thanks

glad to helped you
good luck again

meikl ;-)
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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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