Database Update Allows Additions but not Deletions?

Hi,

I’ve created some code to add new rows to my database which works fine, and after restarting the program, all new rows are still there. (I’ve modified the database parameter from ‘Do not copy‘ to ‘Copy if newer’.)

Another subroutine I’ve created removes certain rows. While the program is running this works fine! However, when I restart the program the deleted rows are back in the database!

This seems really strange! I can add new rows which are updated to the database, but deleted rows are not being properly deleted from the database, because when I restart the program they are back. It seems the database is allowing additions but not deletions

Any one got any ideas what might be causing this

Many thanks,

Dave.



Answer this question

Database Update Allows Additions but not Deletions?

  • GKRAO

    Check that the delete method in the table adapter is coded.

    Remember that the Dataset is a local copy of the data and not the database records themselves. SO you may have an Insert Method but no Delete method on the table adapter - that way when you run an update the insertion of records from the dataset to the database would happen but the deletes couldnt happen as there isnt a command to run.

    Therefore when you reload the records you'd deleted from the dataset would still exists in the database and upon re filling the dataset you'd see them come back.


  • TJSR

    No.

    We'd need to see the code first.



  • GregorHagedorn

    The best way to check if the delete method exists is to open the Dataset Designer by double-clicking on your dataset in the Solution Explorer. After the designer is open click on the TableAdapter in the designer and then look at the Properties Window. There is a property called "DeleteCommand". If the command was generated then you should be able to expand this property and see what the exact command was that you generated. If it wasn't generated the property should have a value of "Nothing".

  • agnerc

    Hey Spotty,

    Thanks for the response.

    How do I check that the delete method in the tableadapter is coded Also, if it's not, how do I code or generate it

    I think you've hit the nail on the head! My code works fine, so I suspected the problem was elsewhere.

    Thanks!


  • Belliez

    hi,

    you can check this thread it has the same question

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=428109&SiteID=1

    hope this helps



  • Database Update Allows Additions but not Deletions?