我正在做一个有关程序,以下是动态创建表source code example:
我用dbaseIV , 其它也类似吧
//表名:
CurrTable :='ZJ'+Copy(FormatFloat('0000',Year),3,2);
Table1.Active := False;
Table1.DatabaseName := 'KjScada';
Table1.TableType := ttDbase;
Table1.TableName := CurrTable ;
if not Table1.Exists then
begin
with Table1.FieldDefsdo
begin
Clear;
Add('NO', ftInteger, 0, False);
Add('LOC1', ftFloat, 0, False);
Add('LOC2', ftFloat, 0, False);
Add('TIME', ftString,8, False);
Add('DATE', ftString, 8 , False);
end;
Table1.CreateTable;
Table1.Active := True;
end else
begin
Table1.Active := True;
Table1.Append;
Table1.FieldByName('Centerid').asinteger := 1;
Table1.FieldByName('NO').asinteger := GetInterID(PkgStr);
Table1.FieldByName('LOC1').asfloat := Zj_Formula(GetDataVal(PkgStr,1),GetInterID(PkgStr),1);
Table1.FieldByName('LOC2').asfloat := Zj_Formula(GetDataVal(PkgStr,2),GetInterID(PkgStr),2);//赋值
Table1.FieldByName('Date').asstring := DatetoSTr(date);
Table1.FieldByName('Time').asstring := TimetoStr(Time);
Table1.Post;
end;