none
Compound Key Update Failure RRS feed

  • General discussion

  • We've just had a strange problem with a table adpter for a table with a compound key made up of 3 integers.  During unit testing, we were getting intermitted but very regular primary key violations.  I traced both the .NET code and the SQL input using the SQL Profiler, and there definitely no duplicate key values being inserted.  After the SqlClientException was thrown during the test, the test values that had generated the error were all successfully inserted into the database.

    I double checked this several times: no actual duplicate values in the SQL Profiler trace, and all values made it in to the database OK.  I also double-checked that this was a SQLClientException and not a data set contraint error.  The update that was triggering this problem was a table with between 2 - 8 new rows to insert.  There were no updates in this particular test, only inserts. 

    Has anyone else seen this?  At this point I'm assuming that this is a SqlClient issue, but if this could somehow be a problem with the code, I'd be interested in hearing what might be wrong.

    • Moved by Chris Robinson- MSFT Wednesday, July 8, 2009 5:26 PM Since there is a SqlClient error raised and not a Constraint this is likely a provider issue (From:ADO.NET DataSet)
    Wednesday, July 8, 2009 12:07 AM

All replies

  • Here's an update: we have found a workaround for this problem.  If the table is initialized by a data adapter using a Fill() method, then the problem goes away.  All of the other details of the scenario are the same, because the Fill() in this test scenario uses a SQL query with a criteria that matches no records.  Apparently the call to Fill() is initializing the empty table in some way that prevents the error on Update().
    Wednesday, July 8, 2009 10:17 PM