Dataset ForeignKeyConstraint Error

O

oj

I have a dataset with a parent table and 3 child tables. The dataset
is filled and manipulated on one particular web page. During the user
interaction one of the child tables can have records inserted,edited,
or deleted. Upon clicking save I call the Update method of my
dataAdapter mapped to the child table in my db and pass the dataset
childtable in as a parameter. I'm getting an inconsistent foreign key
constraint error. The error is telling me that a certain child key
value(1768) must exist in the parent table. The value I'm being given
is the parent primary key of one of the records in my database. The
strange thing is upon entry into the aspx page an entirely different
parent record and related children records were loaded into the
dataset. How am I getting this rogue child record in my dataset for an
entirely different parent record than the one I'me inserting child
records for? I thought I may be loading my dataset with more child
rows than I wanted but my dataset should give the same foreign key
constraint error if I try loading rogue child records without the
parent record in the parent datatable. Anyone seen this type of
bahavior before? I had a hunch that the auto generated SELECT
statement appended to the INSERT statement of my dataadapter may be
causing the issue so I got rid of it. Seems to have solved the
problem, but I would like to know if this truly is the solution, or if
I'm missing something else?

Any suggestions on how to properly debug this error or alternate
solutions are appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top