king_Cai
Unregistered / Unconfirmed
GUEST, unregistred user!
C
curioussea
Unregistered / Unconfirmed
GUEST, unregistred user!
G
gdtkd
Unregistered / Unconfirmed
GUEST, unregistred user!
K
kingdeezj
Unregistered / Unconfirmed
GUEST, unregistred user!
K
king_Cai
Unregistered / Unconfirmed
GUEST, unregistred user!
S
sundart
Unregistered / Unconfirmed
GUEST, unregistred user!
Z
zxb200
Unregistered / Unconfirmed
GUEST, unregistred user!
B
blueboy
Unregistered / Unconfirmed
GUEST, unregistred user!
L
lang_kkl
Unregistered / Unconfirmed
GUEST, unregistred user!
我从前作的一个程序,动态选择表格,当选择一个表格时
得到该表的所有索引(包括主健)及该索引对应的字段。
procedure TForm.cbxSourceTableChange(Sender: TObject); //选择表格时得到索引及字段
begin
...
tblSource.Active := false;
tblSource.IndexName := '';
tblSource.TableName := cbxSourceTable.Items[cbxSourceTable.itemindex];
//tblSource.GetIndexNames(cbxIndexName.Items);
tblSource.IndexDefs.Update;
for i := 0 to tblSource.IndexDefs.Count - 1 do
begin
cbxIndexName.Items.Add(inttostr(i) + '-' + tblSource.IndexDefs.Name);
cbxIndexField.Items.Add(tblSource.IndexDefs.Fields);
// tblSource.Active := true;
end;
end;
procedure TForm.cbxIndexnameChange(Sender: TObject); //用户选择索引时判断索引类型
begin
//将BDE识别的索引显示出来
cbxIndexField.ItemIndex := cbxIndexName.ItemIndex; //显示该索引对应字段
edtIndexType.Text := '';
if ixPrimary in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + '主健' + ';';
if ixUnique in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + '唯一性索引' + ';';
if ixDescending in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + '降序' + ';';
if ixCaseInsensitive in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + '不区分大小写' + ';';
if ixExpression in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + 'dBase关键字索引' + ';';
if ixNonMaintained in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + '自动维护索引' + ';';
if edtIndexType.Text = '' then
edtIndexType.Text := edtIndexType.Text + '一般索引' + ';';
end;
得到该表的所有索引(包括主健)及该索引对应的字段。
procedure TForm.cbxSourceTableChange(Sender: TObject); //选择表格时得到索引及字段
begin
...
tblSource.Active := false;
tblSource.IndexName := '';
tblSource.TableName := cbxSourceTable.Items[cbxSourceTable.itemindex];
//tblSource.GetIndexNames(cbxIndexName.Items);
tblSource.IndexDefs.Update;
for i := 0 to tblSource.IndexDefs.Count - 1 do
begin
cbxIndexName.Items.Add(inttostr(i) + '-' + tblSource.IndexDefs.Name);
cbxIndexField.Items.Add(tblSource.IndexDefs.Fields);
// tblSource.Active := true;
end;
end;
procedure TForm.cbxIndexnameChange(Sender: TObject); //用户选择索引时判断索引类型
begin
//将BDE识别的索引显示出来
cbxIndexField.ItemIndex := cbxIndexName.ItemIndex; //显示该索引对应字段
edtIndexType.Text := '';
if ixPrimary in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + '主健' + ';';
if ixUnique in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + '唯一性索引' + ';';
if ixDescending in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + '降序' + ';';
if ixCaseInsensitive in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + '不区分大小写' + ';';
if ixExpression in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + 'dBase关键字索引' + ';';
if ixNonMaintained in DataModule2.tblSource.IndexDefs[cbxIndexName.ItemIndex].Options then
edtIndexType.Text := edtIndexType.Text + '自动维护索引' + ';';
if edtIndexType.Text = '' then
edtIndexType.Text := edtIndexType.Text + '一般索引' + ';';
end;
P
pp虫
Unregistered / Unconfirmed
GUEST, unregistred user!
var
i:integer;
begin
Table1.Active := False;
Table1.Exclusive := True;
Table1.IndexDefs.Update;
for i:=0 to Table1.IndexDefs.Count-1 do
begin
if ixPrimary in Table1.IndexDefs.Options then
begin
Memo1.Lines.Add('主键名称:'+Table1.indexDefs[0].Name);
Memo1.Lines.Add('主键字段:'+Table1.IndexDefs[0].Fields );
end;
end;
end;
i:integer;
begin
Table1.Active := False;
Table1.Exclusive := True;
Table1.IndexDefs.Update;
for i:=0 to Table1.IndexDefs.Count-1 do
begin
if ixPrimary in Table1.IndexDefs.Options then
begin
Memo1.Lines.Add('主键名称:'+Table1.indexDefs[0].Name);
Memo1.Lines.Add('主键字段:'+Table1.IndexDefs[0].Fields );
end;
end;
end;
Z
zhumoo
Unregistered / Unconfirmed
GUEST, unregistred user!
B
BigFan
Unregistered / Unconfirmed
GUEST, unregistred user!
L
lang_kkl
Unregistered / Unconfirmed
GUEST, unregistred user!
Z
zxb200
Unregistered / Unconfirmed
GUEST, unregistred user!
H
hbezwwl
Unregistered / Unconfirmed
GUEST, unregistred user!
P
Pipi.
Unregistered / Unconfirmed
GUEST, unregistred user!
ADO:
var
ds:TADODataSet;
ds:=TADODataSet.Create(Application);
ADOConnection1.OpenSchema(adSchemaPrimaryKeys,EmptyParam,EmptyParam,ds)
ds的每行的 COLUMN_NAME 列加起来就是全部primary key了
var
ds:TADODataSet;
ds:=TADODataSet.Create(Application);
ADOConnection1.OpenSchema(adSchemaPrimaryKeys,EmptyParam,EmptyParam,ds)
ds的每行的 COLUMN_NAME 列加起来就是全部primary key了
V
vickymade
Unregistered / Unconfirmed
GUEST, unregistred user!
A
akaiwei
Unregistered / Unconfirmed
GUEST, unregistred user!
K
king_Cai
Unregistered / Unconfirmed
GUEST, unregistred user!
K
king_Cai
Unregistered / Unconfirmed
GUEST, unregistred user!