I think it is the conflict between foreign key constraint.
This is the error . could you explain me why i getting this error?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sandeep Singh ShekhawatRank #147 · 15.6K reputationPosted Jul 17, 2013, 3:54 AM EDT
You have two table that has foreign key relation on "divisionId" field. You should first insert value in your referenced table afterthat value will be insert in child table.
So first execute insert statement for referenced table thereafter you execute your insert query.
Thanks
Kunal VaishyaRank #990 · 2K reputationPosted Jul 17, 2013, 4:06 AM EDT
Bineesh ViswanathRank #1,681 · 907 reputationPosted Jul 17, 2013, 7:28 PM EDT
I have a table named tbl_Division and tbl_Student.
here the table where divisionId is PK;
I write code in the btnSave Click event in frmStudent is;
infostudent.divisionId=decimal.parse(cmbdivision.selectedindex.Tostring());
I checked in its Allow Null column in tbl_Student. here is the tbl_Student.
you can see the allow nulls column of divisionId is checked. Is this the problem?
which is referenced table and child table?
please explain
Sandeep Singh ShekhawatRank #147 · 15.6K reputationPosted Jul 17, 2013, 8:17 PM EDT
Here tbl_Division is referenced table where row would be insert first and tbl_Student is child table where row would be insert after.
Allow null means it can have null values its not matter when it is not used as reference filed for foreign key. But it is using as reference field b/w these two table and DivisionId is primary key in
table tbl_Division so it can't not be null in table tbl_Division so it also can't be null in tbl_Student also because it is foreign key in table tbl_Student.We know that DesisionId will not be null in tbl_Division so its child table tbl_Student DivisionId field can't be null.
Suppose we insert a null value in child table tbl_Student DivisionId field that how can we map this value in refernced table tbl_Division?