I have found 'a' solution to my problem.
In the form I added buttons to, I discovered two lines
which are probably at fault that were in the "Web Form
Designer Generated Code" part.
The following two lines added a constraint on one
particular table (even though my dataset has 5 more) which
obviously caused the problem as there is already a
constraint in the dataset itself.
Me.EwsDS.ewsLinksGroupRole.Constraints.AddRange(Ne w
System.Data.Constraint() {New
System.Data.UniqueConstraint("EwsLinksDSKey5", New String()
{"roleId", "linkGroupId"}, True)})
Me.EwsDS.ewsLinksGroupRole.TableName = "ewsLinksGroupRole"
Why these lines appeared, I do not know. Especially since
adding buttons that were not databound had caused it.
The following newsgroup article assisted me to pinpointing
a solution to my problem:
http://groups.google.com.au/groups?h...3DN%26tab%3Dwg -----Original Message-----
Hi,
I am getting the following error when I run my Visual Basic
application:
"Cannot add primary key constraint since primary key is
already set for the table"
I am using datasets with primary keys which are filled from
an SQL Server database. These datasets were automatically
generated in Visual Studio.
Now, the application worked fine for a while until I added
buttons onto a form. I did not touch any datasets or the
data in the database. I did not touch the file in which the
error is thrown.
Does anybody know what causes this error? I have searched
extensively on Microsoft and Google, and the only solution
I can find is to remove the primary key constraints in the
dataset. I would be grateful if there was another solution
to this rather frustrating problem.
Thankyou
Stephen.
.