I know that this isn't a C# question, but I can't find a newsgroup
specifically devoted to ADO.NET, other than a moribund one that deals
with ADO in general.
This problem is driving me to distraction. Maybe someone else has run
across the same thing.
I'm using ODBC to build a joined table in ADO.NET. The table has a
large number of columns, but only one key column, which has the usual
TABLE1.STOCK_CODE = TABLE2.STOCK_CODE "where" clause to do the join.
This all works fine.
In fact, we have two dozen such table pairs, and it works great for all
but one of them.
For that one pair of tables, I get the data back fine, but when I
attempt to set the primary key column:
table.PrimaryKey = keyColumns;
I get an error:
System.ArgumentException: These columns don't currently have unique
values.
Before you jump on that, yes, I know exactly what that error means: the
joined table (somehow) has two identical stock codes in it.
The only problem is that it doesn't.
I've extracted data from the background tables, sorted it, and ran
comparisons. No duplicates.
I've written code that runs through the ADO.NET table I have in memory
comparing keys. No duplicates.
I've written the keys from the ADO.NET table I have in memory out to a
text file, which I sorted and checked. No duplicates.
Does anyone know how ADO.NET determines uniqueness for key values? Does
anyone know how to get ADO.NET to give up which rows it thinks are
colliding when trying to set primary keys? There are 7482 rows in the
joined table, and every key appears to be unique. Can anyone suggest
something I haven't tried yet to figure out why ADO.NET refuses to set
this column as a primary key column?