SqlServer: How to know if a a column is a primary key ?

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

I have a database-generic application.
CommandBuilder is not satisfactory.
I try to generate my own command automatically but:

I can't get PrimaryKey information !

I create a
IDbCommand cmd;.
cmd.CommandText = SELECT * FROM Table
IDataReader dr = cmd.ExecuteReader(CommmandBehavior.SchemaOnly)

and then I analyse
dr.GetSchemaTable()

the column "IsKey" is always set to DBNull.Value, at last on the PocketPC
(with the compact framework)

I know there is plenty of meta table in SqlServer.
which one should I query to get primary key information ?
 
don't worry, found it.
see my previous similar post ...

anyway, still a bug in the schema table.
 
Back
Top