Dynamic building table (example)

xiaoxiao2021-03-06  82

Begin

With table1 do

Begin

Active: = FALSE;

DatabaseName: = 'Doctor';

Tabletype: = TTPARADOX;

TableName: = 'Doctorinf23';

IF not table1.exists the begin

With Fielddefs Do Begin

Clear;

With addfielddef do begin

Name: = 'Name';

DataType: = ftstring;

REQUIRED: = True;

SIZE: = 10;

END;

With addfielddef do begin

Name: = 'age';

DataType: = ftinteger;

End; // Set the word Decision, add a new TFieldDef object with the AddFieldDef method

With addfielddef do begin

Name: = 'title';

DataType: = ftstring;

REQUIRED: = True;

SIZE: = 10;

END;

END;

With indexdefs do begin

Clear;

With addressexdef do begin

Name: = 'MyIndex';

Fields: = 'Name';

Options: = [xiprimary];

END;

END; / / Establish index

END;

CreateTable;

END;

//Table1.Append;

Table1.open;

Table1.edit;

Table1.fieldbyname ('Name') .sstring: = 'Liu Yan';

Table1.fieldbyname ('age') .asinteger: = 22;

Table1.fieldByname ('title') .sstring: = 'physician';

Table1.Append;

Table1.edit;

Table1.fieldbyName ('Name') .sstring: = 'Yang Xiao';

Table1.fieldbyname ('age') .asinteger: = 25;

Table1.fieldByname ('title') .sstring: = 'physician';

DBGRID1.DATASOURCE: = DataSource1;

Table1.Active: = true;

END;

转载请注明原文地址:https://www.9cbs.com/read-104785.html

New Post(0)