怎么动态创建索引并按新建的索引排序,和动态修改数据库字段名类型与字段名称?(100分)

  • 主题发起人 紫风铃
  • 开始时间

紫风铃

Unregistered / Unconfirmed
GUEST, unregistred user!
怎么动态创建索引并按新建的索引排序,和动态修改数据库字段名类型与字段名称?
我希望看到一段小代码来实现上面的功能。
 
你是用什么类型的数据库
开发工具又是啥
 
to 笑傲江湖:
我用的开发工具是Delphi4/5 , 数据库是DBE;
 
你这个问题有些广!一时不好说!最好的办法是看帮助里面的例子!
索引的排序大概是:
再新建一个索引
最后调用这个索引
而且不能用Database Desktop建立索引!否则会出错!!
table1.addindex('', '主索引字段', [ixPrimary, ixUnique]);
’’里一定要为空!
table1.addindex('索引名', '索引字段', [ixCaseInsensitive]);
table1.open;
table1.IndexName:='索引名';
搞定!
动态修改数据库字段名类型与字段名称 还是自己看帮助吧!
 
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;
 
谢谢:
问题已经解决能够动态的建立索引。
这里还有一个帖子:< 拨号服务器的地址 >
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
949
SUNSTONE的Delphi笔记
S
S
回复
0
查看
770
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
顶部