467,077 Members | 1,016 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

Dataset ForeignKeyConstraint Error

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.
Nov 18 '05 #1
  • viewed: 1295
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dennis | last post: by
1 post views Thread by David A. Osborn | last post: by
8 posts views Thread by Harry Strybos | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.