Quote:
Originally Posted by kermit1965
Sorry I was not precise. The code was only creating three methods. I did not intend that they be run sequentially.
|
I was refering to your Delete Method only.
Imagine:
You have one dinner with dinnerID = 1
You have two RSVP's with dinnerID = 1 and RSVPID = 1 and 2.
In your foreach loop the following will happen:
First loop:
It finds RSVP with RSVPID 1 and deletes it (OK)
It then tries to delete the dinner, but will fail with an exception error as there is a connection to RSVP where RSVPID = 2.
Therefore:
Take the deletion of the dinner outside and after the foreach loop.
Hope this clarifies.