ADO.Net 2.0 ; SqlDataReader.GetSchemaTable broken?

A

ajj3085

Hi all,

I'm using the GetSchemaTable method on a data reader to determine
information about the table itself. One of the DataRow's items is
supposed to include IsKey, which tells me if the column is part of the
primary key or not.

I have a simple table with an Int identity as the primary key, but
IsKey is returning a null value..neither true or false. Is this a bug
in the framework? IsIdentity does return correctly as do most of the
other properties i've examined.

Thanks
Andy
 
G

Guest

Andy,

This works for me in ADO.Net 1.1:

rdr = cmd.ExecuteReader(CommandBehavior.SchemaOnly Or CommandBehavior.KeyInfo)

Kerry Moorman
 
D

David Sceppa [MSFT]

Kerry is correct. You need to include KeyInfo in the CommandBehavior
specified when calling ExecuteReader. Otherwise, key information is not
included with the resultset.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2006 Microsoft Corporation. All rights reserved.
 
A

Andy

David,

Thanks for the response; I'll give it a shot.

FYI, Kerry's response never appeared for me under this thread..weird.

Andy
 
D

David Sceppa [MSFT]

No problem. And it's definitely odd that Kerry's reply didn't show up
as part of the thread. Just so Kerry gets proper credit/kudos, here's that
post:
This works for me in ADO.Net 1.1:
rdr = cmd.ExecuteReader(CommandBehavior.SchemaOnly Or CommandBehavior.KeyInfo)

Kerry Moorman

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2006 Microsoft Corporation. All rights reserved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top