I am filling a datatable
object through a dataadapter
pulling data from a MS-SQL
database. For some reason the wrong column is set as the primary key on the datatable. I have tried FillSchema
and MissingSchemaAction.AddWithKey
to no avail.
The correct primary key is defined properly in the SQL server DB schema & is backed by a non clustered unique index PK_x
.
The column selected as the primary key by the dataadapter is a unique column backed by a clustered unique index.
These are the only two columns in the table.
How does DataAdapter retrieve the table schema from SQL? I have interrogated the sys tables (sys.tables, sys.index_columns, sys.indexes) and they indicate the proper primary key schema. What gives?