Search code examples
c#mysqltriggersmyisambindingsource

Prevent deletion for specific id


For ex I have a table1 with id and name field. I use bindingsource to bind data to datagridview. Now I expect that user can not delete row which table1.id = 1 or table1.id = 2.

How to do that either use C# code or trigger in MYSQL.

ps : I use save button on the bindingnavigator to update data. It's generated after I drag a dataset to winsform.

Thank in advance !


Solution

  • use a trigger - some general pointers:

    EDIT - as per comments:

    see http://www.brokenbuild.com/blog/2006/08/15/mysql-triggers-how-do-you-abort-an-insert-update-or-delete-with-a-trigger/