var
keyField : array of string;
KeyCount : integer;
i , cc, st : integer;
IndexDefs := Table1.IndexDefs;
for i := 0 to IndexDefs.Count-1 do
begin
if IndexDefs.Items[i].Name ='PrimaryKey' then
//本段代码只对Access有效
//对SQL server 暂时嘿嘿.... 形式
begin
keyFields := IndexDefs.Items[i].Fields;
cc := 1; keyCount := 0; st := 1;
while cc<=length(keyFields) do
begin
if keyfields[cc] = ';' then
begin
inc(keyCount);
keyField[keyCount] := copy(keyFields, st, cc-st);
st := cc + 1;
end;
inc(cc);
end;
inc(keyCount);
keyField[keyCount] := copy(keyFields, st, cc-st+1);
end;
end;