violation unique key constraint [solved]
yes - this is a wierd one which i havent encountered before. when the tableadapter's update command is called I get this error.
Code:
"System.Data.SqlClient.SqlException: Violation of UNIQUE KEY constraint 'IX_ReportColumn'. Cannot insert duplicate key in object 'ReportColumn'.
The statement has been terminated.
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)
at ReportDataSetTableAdapters.ReportColumnTableAdapter.Update(ReportColumnDataTable dataTable) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\website\c7de1566\f50d71c3\App_Code.qbpf4itd.1.cs:line 4112
at _Default.btnSave_Click(Object sender, EventArgs e) in C:\Projects\BE WebReporting\Website\Default.aspx.vb:line 525"
the table itself has a PK and an FK and has a unique constraint of 2 fields. but its calling the update command so I dont quite understand why its performing an insert statement? perhaps its not.... but why would there be duplicate keys being inserted?
Re: violation unique key constraint
figured out why. There was a unique constraint on the table (which shouldnt have existed it as its pointless and useless in this case) which threw the exception. So it was a combination of 2 fields making a unique key constraint which everytime violated when updating a table with values to update....which caused the error
and no it werent me who designed the database ;)