TFieldFieldName (Delphi)

Description

This example displays a message box with
the names of all the fields in a table.

Code

procedureTForm1.Button1Click(Sender:TObject);vari:Integer;Info:String;beginInfo:='The fields of table '+Table1.TableName+' are:'#13#10#13#10;fori:=0toTable1.FieldCount-1doInfo:=Info+Table1.Fields[i].FieldName+#13#10;ShowMessage(Info);end;procedureTForm1.FormCreate(Sender:TObject);beginTable1:=TTable.Create(Form1);withTable1dobeginDatabaseName:='DBDEMOS';TableType:=ttParadox;TableName:='CustInfo';Table1.Active:=False;{ Do not overwrite an existing table. }ifnotTable1.Existsthenbegin{ The Table component must not be active. }{ First, describe the type of table and give }{ it a name. }{ Next, describe the fields in the table. }withFieldDefsdobeginClear;withAddFieldDefdobeginName:='Field1';DataType:=ftInteger;Required:=True;end;withAddFieldDefdobeginName:='Field2';DataType:=ftString;Size:=30;end;end;{ Next, describe any indexes. }withIndexDefsdobeginClear;{ The first index has no name because it is { a Paradox primary key. }withAddIndexDefdobeginName:='';Fields:='Field1';Options:=[ixPrimary];end;withAddIndexDefdobeginName:='Fld2Indx';Fields:='Field2';Options:=[ixCaseInsensitive];end;end;{ Call the CreateTable method to create the table. }CreateTable;end;end;DS2.DataSet:=Table1;DBGrid2.DataSource.DataSet:=Table1;Table1.Active:=True;end;