none
OleDB / Access table - cannot get primary key RRS feed

  • Question

  • I have a local Access database. In my C# application I connect using OleDB. I do a Select * From ATable. The table has 8 columns and 523 rows.

    The first column in the table is set as the Primary Key. Indexed Yes (No Duplicates). Required is Yes.

    I call rdr.GetSchemaTable(). When I examine the DataTable returned for the info on the first column, AllowDBNull is true (should be false), IsUnique is false (should be true), IsKey os false (should be true).

    Why am I getting the opposite of the correct schema values?

    Thanks,

    Jon


    Jon Jacobs
    In transmission, subatomic particles managed by professionals.
    No innocent electrons were harmed.

    Tuesday, April 8, 2014 4:03 PM

Answers

  • >don't...retrieve this schema information using ADO.NET

    I have come to that conclusion too, at least as far as getting it through the reader.

    I made it work by getting the schema through the connection instead.


    Jon Jacobs
    In transmission, subatomic particles managed by professionals.
    No innocent electrons were harmed.

    Wednesday, April 9, 2014 10:58 AM

All replies

  • I don't think you can accurately retrieve this schema information using ADO.NET. I would recommend using either ADOX or DAO (which handles Access specific implementations).

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Tuesday, April 8, 2014 7:31 PM
  • >don't...retrieve this schema information using ADO.NET

    I have come to that conclusion too, at least as far as getting it through the reader.

    I made it work by getting the schema through the connection instead.


    Jon Jacobs
    In transmission, subatomic particles managed by professionals.
    No innocent electrons were harmed.

    Wednesday, April 9, 2014 10:58 AM