DataTable.Load(DataReader) and nullable primary key problem

Discussion in 'Microsoft ADO .NET' started by Reece Laurie, Oct 12, 2009.

  1. Reece Laurie

    Reece Laurie Guest

    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...
     
    Reece Laurie, Oct 12, 2009
    #1
    1. Advertisements

  2. 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
     
    Colbert Zhou [MSFT], Oct 13, 2009
    #2
    1. Advertisements

  3. Reece Laurie

    Reece Laurie Guest

    Hi,

    IDS is the Informix Dynamic Server.

    Thanks,
    Reece
     
    Reece Laurie, Oct 13, 2009
    #3
  4. 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
     
    Colbert Zhou [MSFT], Oct 15, 2009
    #4
  5. Reece Laurie

    Reece Laurie Guest

    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?
     
    Reece Laurie, Oct 15, 2009
    #5
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. srinivas moorthy

    Re:DataAdapter, DataTable & primary key

    srinivas moorthy, Jul 28, 2003, in forum: Microsoft ADO .NET
    Replies:
    0
    Views:
    309
    srinivas moorthy
    Jul 28, 2003
  2. Guest
    Replies:
    9
    Views:
    1,162
    Jon Skeet [C# MVP]
    May 23, 2004
  3. deko
    Replies:
    6
    Views:
    1,634
    Patrice
    Mar 14, 2006
  4. 0to60
    Replies:
    2
    Views:
    4,886
    William \(Bill\) Vaughn
    Jul 5, 2007
  5. Reece Laurie
    Replies:
    1
    Views:
    2,864
    Colbert Zhou [MSFT]
    Nov 18, 2009
Loading...

Share This Page