PC Review


Reply
Thread Tools Rate Thread

DataTable.Load(DataReader) and nullable primary key problem

 
 
Reece Laurie
Guest
Posts: n/a
 
      12th Oct 2009
Hi,

Scenario: IDS allows PK to be defined as Null-able. Our code sets the
metadata of the select command's data reader correctly by setting the IsKey
property of the PK columns to "True".

Problem. The DataTable.Load(DataReader) action with the above scenario
doesn't set the DataTable's PrimaryKey property.

I.e.

after running
DataTable.Load(Command.ExecuteReader(CommandBehavior.SchemaOnly |
CommandBehavior.KeyInfo)) with the SELECT * FROM T command where T is a
table with nullable PK, the DataTable.PrimaryKey array is empty, even though
the DataReader.GetSchemaTable() correctly shows IsKey=True for the PK
columns.

I'd like an explanation as to why they think PK is not being set. Is there
anything else that we should be setting for the PK to be set properly? If
IsKey is the only property that matters, then, since we're setting it, this
is a defect that should be fixed?

Thanks...


 
Reply With Quote
 
 
 
 
Colbert Zhou [MSFT]
Guest
Posts: n/a
 
      13th Oct 2009
Hello Reece,

I intend to help on this but do not catch the scenario very well. When you
say,
"IDS allows PK to be defined as Null-able."

What do you mean about the IDS? As far as I know, SQL Server does not
support a nullable Primary Key. Would you mind clarifying so that I can do
more research from my side and try to give help on this.

Have a nice day!


Thanks,
Ji Zhou
Microsoft Online Community Support Team

 
Reply With Quote
 
 
 
 
Reece Laurie
Guest
Posts: n/a
 
      13th Oct 2009
Hi,

IDS is the Informix Dynamic Server.

Thanks,
Reece


 
Reply With Quote
 
Colbert Zhou [MSFT]
Guest
Posts: n/a
 
      15th Oct 2009
Thanks Reece! But the Informix Dynamic Server is an IBM product that we do
not support. Even I really intend to help on this, but there are many
factors that determine it is hard to repro, investigate this issue in our
side. Indeed the underlay Data Provider IBM.DATA.DB2.dll is also not from
Microsoft. If the IDS supports the nullable PK, their Data Provider should
be responsible to set the PK right when filling the data table.

By the way, technically speaking, you can try to use Reflector to see the
Data Provider's implementation. It may show what it has done and why it
does not set the PK correctly.


Best regards,
Ji Zhou
Microsoft Newsgroup Support Team

 
Reply With Quote
 
Reece Laurie
Guest
Posts: n/a
 
      15th Oct 2009
IBM's provider extends the System classes and in case of DataTable relies
fully on the Microsoft's implementation. What we'd like to find out is what
conditions does the DataTable.Load() checks in order to set the PrimaryKey
attribute. The MSDN description of the Load(IDataReader) method states that,
in the case when DataTable has no schema, one is inferred from the
IDataReader's result set. I'd like to know what rules are used to infer the
schema. I'm assuming IDataReader.GetSchemaTable() is called for that. If so,
what column attributes are looked at when setting the PrimaryKey property?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do I have to set the primary key to include primary key fields? boooney Microsoft Access Database Table Design 3 15th Apr 2010 12:17 AM
Difference between nullable class and nullable<> structure Raj Microsoft C# .NET 31 19th Oct 2009 11:01 PM
Data Primary key vs. Artificial (Autonumber) primary key M. Microsoft Access Database Table Design 78 14th Dec 2007 10:10 AM
nullable types. why no support for nullable string Sakoulakis Microsoft C# .NET 3 6th Aug 2004 03:41 PM
Cannot add primary key constraint since primary key is already set for the table Microsoft VB .NET 1 3rd Dec 2003 02:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:59 PM.