Prevent deletion for specific id
For ex I have a table1 with id and name field. I use bind开发者_开发百科ingsource 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 !
use a trigger - some general pointers:
- http://net.tutsplus.com/tutorials/databases/introduction-to-mysql-triggers/
- http://dev.mysql.com/doc/refman/5.5/en/signal.html
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/
Put a "where"
Condition while deleting that
Delete from table1 where table1.id != 1 OR table1.id != 2
精彩评论