Re: TZF - Opening DBF at runtime
Eitan Gilboa <[email protected]> Fri, 11 Jul 2003 21:35:26 +0200
| Newsgroups | gmane.comp.lang.delphi.topaz |
|---|---|
| Message-ID | <[email protected]> |
Marie,
>> I believe you always have to have a structure pre-defined, either using
a dummy file or in code.
Not really... You can create, open and use a DBF at run time like so:
Here's essentially what you need to do in order to create a DBF at run time:
{type- must be a valid dBASE type, like: 'C') }
procedure TForm1.Button1Click(Sender: TObject);
VAR dbf: TTzDbf;
begin
dbf := TTzDbf.Create(Application); { create an instance of TTzDbf }
try
dbf.DbfFields.Clear;
dbf.DbfFields.Add('FirstN,C,30,0'); { add the fields }
dbf.DbfFields.Add('LasttN,C,30,0');
dbf.DbfFields.Add('Phone,C,12,0');
dbf.DbfFields.Add('amount,N,10,2');
dbf.DbfFilename := 'c:\MyDbf.dbf';
dbf.Active := TRUE;
dbf.Active := FALSE; { That's it! }
finally
dbf.Free;
end;
end;
Best wishes,
Eitan.
URL: http://perso.wanadoo.fr/eitang
==^================================================================
This email was sent to: [email protected]
EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]
TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
==^================================================================