Can someone tell me why my dataset wont save correctly to the database in simple winforms app?

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-03-29T22:41:29Z Indexed on 2010/03/29 22:43 UTC
Read the original article Hit count: 176

Filed under:
|
|

I have been struggling with this all day and I know it is probably something stupid. My code is below. If I call save then exit my program and start again I can save images to my events but if I just call save when I try to add an image and call save again I get a foreign key error. From what I know I thought my save method was updating the database from my dataset so the event associated with the image should exist. Anyway here is my save method...

Private Sub Save()
    Me.Validate()

    EventsBindingSource.EndEdit()
    ImagesBindingSource.EndEdit()

    TableAdapterManager.UpdateAll(EventDataSet)
    EventDataSet.AcceptChanges()        
End Sub

Am I doing this wrong? Is this enough detail?

© Stack Overflow or respective owner

Related posts about winforms

Related posts about .NET