Error on SubmitChanges
Posted: Mon 31 Oct 2011 17:50
I have two tables.
Table1:
Id Int Not Null, Auto Increment, Primary Key,
Name Varchar(100)
Table2:
Table1Id Int Not Null Primary Key, Foreign Key to Table1,
Name Varchar(100)
table1 = new Table1();
table1.Name = "Test1";
table2 = new Table2();
table2.Name = "Test2";
table2.Table1 = table1;
On SubmitChanges it throws the error "The INSERT statement conflicted with the FOREIGN KEY constraint...", but if I add another table, let's say, Table3 and make the Table2 refrences the Table3, it works.
What am I doing wrong?
If additional information on the code is necessary, just ask.
Thanks.
Table1:
Id Int Not Null, Auto Increment, Primary Key,
Name Varchar(100)
Table2:
Table1Id Int Not Null Primary Key, Foreign Key to Table1,
Name Varchar(100)
table1 = new Table1();
table1.Name = "Test1";
table2 = new Table2();
table2.Name = "Test2";
table2.Table1 = table1;
On SubmitChanges it throws the error "The INSERT statement conflicted with the FOREIGN KEY constraint...", but if I add another table, let's say, Table3 and make the Table2 refrences the Table3, it works.
What am I doing wrong?
If additional information on the code is necessary, just ask.
Thanks.