G
Guest
Hi, first of all, I'm using:
Microsoft Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727
Installed Edition: C# Express.
I have added a DataSet to my Form manually and also manually populated it
with tables (columns and primary keys), and Relations.
At first all was working well, but after I extended my DataSet to include
more tables and relations my application wouldn't run anymore because as soon
as InitializeComponent() of the main form gets to this line:
((System.ComponentModel.ISupportInitialize)(this.dataSetFrmMain)).EndInit();
I get an exception:
System.Data.DataException was unhandled
Message="Constraint matches constraint named Constraint1 already in
collection."
Source="System.Data"
StackTrace:etc..
After some investigating I figured out that the designer generated code for
my dataset named every unique primary key constraint "Constraint1". To see
this one would select the dataset, open its properties window, pick tables,
select one and view the Constraints property. There you can manually edit the
Constraint name, which I did for all my PK constraints. Also note that you
have to remove (and later recreate) all FK constraints that rely on a given
PK before you can do that (a tedious process may I note). Then all was
working well again.
The next time I wanted to extend my dataset (that be now) I found my self
facing the same nice little exception. I removed every PK and relation. Then
I went on to add them again (there you can see for yourself that as you add a
PK to a table the designer conveniently names every PK constraint
"Constraint1", and the application runs normally regardless. However, when
you add Relations, the runtime suddenly realizes all its unique PK
constraints are named the same and everything crashes.
On top of it all, try just to change the constraints names from
"Constraint1" to whatever, leave it with just the PK's there, don't add any
relations, save, exit VS and reload. Surprise! Every constraint is named
"Constraint1" again! The problem must be somewhere therein.
Can this be fixed or am I condemned to eternal renaming of my constraints?
Thank you very much![Smile :) :)](/styles/default/custom/smilies/smile.gif)
Microsoft Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727
Installed Edition: C# Express.
I have added a DataSet to my Form manually and also manually populated it
with tables (columns and primary keys), and Relations.
At first all was working well, but after I extended my DataSet to include
more tables and relations my application wouldn't run anymore because as soon
as InitializeComponent() of the main form gets to this line:
((System.ComponentModel.ISupportInitialize)(this.dataSetFrmMain)).EndInit();
I get an exception:
System.Data.DataException was unhandled
Message="Constraint matches constraint named Constraint1 already in
collection."
Source="System.Data"
StackTrace:etc..
After some investigating I figured out that the designer generated code for
my dataset named every unique primary key constraint "Constraint1". To see
this one would select the dataset, open its properties window, pick tables,
select one and view the Constraints property. There you can manually edit the
Constraint name, which I did for all my PK constraints. Also note that you
have to remove (and later recreate) all FK constraints that rely on a given
PK before you can do that (a tedious process may I note). Then all was
working well again.
The next time I wanted to extend my dataset (that be now) I found my self
facing the same nice little exception. I removed every PK and relation. Then
I went on to add them again (there you can see for yourself that as you add a
PK to a table the designer conveniently names every PK constraint
"Constraint1", and the application runs normally regardless. However, when
you add Relations, the runtime suddenly realizes all its unique PK
constraints are named the same and everything crashes.
On top of it all, try just to change the constraints names from
"Constraint1" to whatever, leave it with just the PK's there, don't add any
relations, save, exit VS and reload. Surprise! Every constraint is named
"Constraint1" again! The problem must be somewhere therein.
Can this be fixed or am I condemned to eternal renaming of my constraints?
Thank you very much
![Smile :) :)](/styles/default/custom/smilies/smile.gif)