ADOX, Delphi 7 and SQL Table Key Information


2006-05-15 05:09:19 AM
delphi79
Hi, I am trying to determine SQL table structures and print them using Word.
Everything is working well apart from my inability to get key field
information.
tbl is an _Table, col is a _Column and colname is just a string in this
coding:
b := tbl.Keys.Count;
if b>0 then
begin
for d:= 0 to (b-1) do
begin
if copy(tbl.Keys[d].Name,0,2) = 'PK' then //assuming that all
primary keys start with PK!
begin
col := tbl.Keys[d].Columns[0];
colname := col.name;
//do something with the column name now that I have got it
end;
end;
//ok, admittedly this would not work fully with a primary key consisting of
multiple fields but I get the message
//that the provider cannot provide the information in the line:
col := tbl.Keys[d].Columns[0];
Can anyone suggest some help please?
Many thanks in anticipation
David Smith