Take the 2-minute tour ×

Microsoft Visual Studio 2008 using Microsoft net framework Version 3.5 SP1

I am attempting to modify a working form. Upon initially adding buttons / fields and then subsequently running the program, the form threw an exception.

Exception :

"ArgumentException was unhandled by user code"
"Cannot add primary key constraint since primary key is already set for the table"

From what I have found it has to do with trying to modify or enforce constraints on an inherited data-table/database. Is there any auto generated which could be causing this error?

Thanks for any help.

share|improve this question
can you show the call stack + offending code –  jeroenh Mar 28 '11 at 15:06
I am not able to show it entirely, –  Josh Mar 28 '11 at 15:10
at System.Data.ConstraintCollection.FinishInitConstraints() at System.Data.DataTable.EndInit() Initialization of components method called. @jeroenh –  Josh Mar 28 '11 at 15:11
We are not able to answer it entirely. –  Hans Passant Mar 28 '11 at 15:31
show 1 more comment

1 Answer

As pointed out in my initial question I was searching for the function that I could delete to keep this from happening. And even though @jeroenh thought so valiantly that I did not give enough information to answer this question, I'd like to point out the function is


^ you'll note it had to do with constraints from a data-table.

share|improve this answer
add comment

Your Answer


