|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ADO.Net 2.0 ; SqlDataReader.GetSchemaTable broken?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 Andy,
This works for me in ADO.Net 1.1: rdr = cmd.ExecuteReader(CommandBehavior.SchemaOnly Or CommandBehavior.KeyInfo) Kerry Moorman Show quote "ajj3***@alum.rit.edu" wrote: > 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 > > 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. David,
Thanks for the response; I'll give it a shot. FYI, Kerry's response never appeared for me under this thread..weird. Andy 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: > Andy, David Sceppa> This works for me in ADO.Net 1.1: > rdr = cmd.ExecuteReader(CommandBehavior.SchemaOnly Or CommandBehavior.KeyInfo) > Kerry Moorman 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. |
|||||||||||||||||||||||