View Single Post
  #7 (permalink)  
Old October 13th, 2010, 05:50 AM
Ole F Ole F is offline
Authorized User
Join Date: Sep 2010
Posts: 13
Thanks: 1
Thanked 1 Time in 1 Post
Default Sorry for not being precise either

Originally Posted by kermit1965 View Post
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.

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.

Take the deletion of the dinner outside and after the foreach loop.

Hope this clarifies.