I'm trying to perform a query that will unable the user to update certain rows with a condition. I know this is done by trigger but I'm still a beginner and I don't know how and how to activate or call that trigger in c# windows forms.
This is my table for example:
tbl_Products (prod_ID, prod_Name, Quantity, Price, Status)
My condition will be for example like:
deny update tbl_products (prod_ID, prod_Name, Quantity, Price) where status = 'sold'
The user will be able to update the product details only when the column status ='no sold'
You don't; triggers are applied at the database server, and will be invoked automatically by
UPDATEstatements. If you've created a trigger that effectively breaksUPDATE, then... I guess that'll work.However, usually you simply (at the application level)... don't update the rows you don't wish to update.
Another option, for reference, is to essentially have two tables - for example
PENDING_PRODUCTSandSOLD_PRODUCTS- and thenREVOKE UPDATE ON SOLD_PRODUCTS(and probablyDELETEtoo), so that you canINSERTinto it only - and perhaps create aVIEW(PRODUCTS) that is a union of the two with a dummy status column that discriminates between them.