Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

Managing *.dbf tables

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
blash
Asked:
blash
  • 2
1 Solution
 
kretzschmarCommented:
if c.dbf already exists,
then use
t.batchmove(query1,BatAppend);
or
t.batchmove(query1,BatUpdateAppend); //??is the name relly so

meikl ;-)
0
 
blashAuthor Commented:
Such a long question, so short the answer!

Thanks meikl :)))
0
 
kretzschmarCommented:
:-) thanks

glad to helped you
good luck again

meikl ;-)
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now