Board index » delphi » How to get primary keys from table ?

How to get primary keys from table ?

Hi

How can I get information about primary keys in table ?
I have Delphi 4.0 and SQL-Server 6.5

Thanks

 

Re:How to get primary keys from table ?


Quote
Koshmaniv Vladimir wrote:
> Hi

> How can I get information about primary keys in table ?
> I have Delphi 4.0 and SQL-Server 6.5

> Thanks

Run through the IndexDefs of a TTable.
On of the indexes will be marked as the primary key. The Options
property from the TIndexDef structure will have a "primary" marking.

At least that is what the BDE help files say, but I found that even
thuogh it may work on Paradox/Interbase, on Oracle the BDE will see only
secondary indexes. The primary index on an Oracle table is not
recognized, but marked as a secondary index instead.

I don't know about SQL server, you should try yourselves.

--
Edwin Teisman, The Netherlands
email: e.teis...@wxs.nl

Re:How to get primary keys from table ?


There is a limitation in the BDE people which prevents the correct setting
of the IndexDefs Primary Key property correctly on ODBC databases. It will
work with Paradox or SQL Links for MS SQL Server.

I say "limitation in the people" because when I complained about this a year
ago, I was told that it might be considered for a low-priority future
"enhancement". Somehow wrong output is not a "bug". If you know how to get
to the ODBC interface yourself, there is a SQLPrimaryKeys function that
returns this information.

Quote
Edwin Teisman wrote:
> Koshmaniv Vladimir wrote:

> > Hi

> > How can I get information about primary keys in table ?
> > I have Delphi 4.0 and SQL-Server 6.5

> > Thanks

> Run through the IndexDefs of a TTable.
> On of the indexes will be marked as the primary key. The Options
> property from the TIndexDef structure will have a "primary" marking.

> ...

--
Kevin Davidson
QS Technologies, Inc.
Suite 1106 NationsBank Plaza, Greenville, SC 29601
ke...@qsinc.com
voice: (864) 232-2666 / fax: (864) 370-2230

Other Threads