请问如何在程序中创建表?

papaya_stone 2002-11-20 08:36:37
???
...全文
27 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
vickeen 2002-11-20
  • 打赏
  • 举报
回复
//delphi中的例子。
The following example shows how to create a table.

{ Don't overwrite an existing table }

if not Table1.Exists then begin
with Table1 do begin
{ The Table component must not be active }
Active := False;
{ First, describe the type of table and give }
{ it a name }
DatabaseName := 'DBDEMOS';
TableType := ttParadox;
TableName := 'CustInfo';
{ Next, describe the fields in the table }
with FieldDefs do begin
Clear;
with AddFieldDef do begin

Name := 'Field1';
DataType := ftInteger;
Required := True;
end;
with AddFieldDef do begin
Name := 'Field2';
DataType := ftString;
Size := 30;
end;
end;
{ Next, describe any indexes }
with IndexDefs do begin
Clear;
{ The 1st index has no name because it is
{ a Paradox primary key }
with AddIndexDef do begin

Name := '';
Fields := 'Field1';
Options := [ixPrimary];
end;
with AddIndexDef do begin
Name := 'Fld2Indx';
Fields := 'Field2';
Options := [ixCaseInsensitive];
end;
end;
{ Call the CreateTable method to create the table }
CreateTable;
end;
end;

呵呵。。。。给分!

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧