ViaThinkSoft CodeLib
This article is in:
CodeLib → Programming aids → Delphi
procedure GetPrimaryKeyNames(con: TADOConnection; TableName: string; outsl: TStrings);
var
ds: TADODataSet;
begin
ds := TADODataSet.Create(nil);
try
con.OpenSchema(siPrimaryKeys, Unassigned, EmptyParam, ds);
while not ds.Eof do
begin
if ds.FieldByName('TABLE_NAME').AsString = TableName then
begin
outsl.Add(ds.FieldByName('COLUMN_NAME').AsString);
end;
ds.Next;
end;
finally
ds.Free;
end;
end;
GetPrimaryKeyNames(ADOConnection1, 'CUSTOMERS', Memo1.Lines);
Daniel Marschall
ViaThinkSoft Co-Founder
ViaThinkSoft Co-Founder