Hi

i m working with ASP.Net, C#

i need to have an example of trigger

how to call it from C#, and how to execute???

Recommended Answers

All 8 Replies

what kind of trigger do you mean?

you dont call a trigger from asp.net, sql trigger is constructed in sql server and it listens for the changes in the specified table(updates, deletes, inserts) .If specified table is modified, then trigger do some changes according to what it is told to.
take this for an example : you have related tables, when the parent table row is deleted you want to delete all the childrows of that parent row, then you specify a trigger for the parent table and tell it to delete all the records in the corresponding child table when a row deleted from the parent table.

Read up on Primary keys and Foreign keys. This is how you relate the tables together with a trigger to delete all childrows or update all childrows when the parent row is modified or deleted. This is all done on the server, so if you wish for an explanation of triggers, please visit the MS SQL portion of this site at: http://www.daniweb.com/forums/forum127.html

hi i want example for trigger

{CREATE | RECREATE | CREATE OR ALTER} TRIGGER name FOR {TABLE name | VIEW name}
[ACTIVE | INACTIVE]
{BEFORE | AFTER}
{INSERT [OR UPDATE] [OR DELETE] | UPDATE [OR INSERT] [OR DELETE] | DELETE [OR UPDATE] [OR INSERT] }
[POSITION n] AS
BEGIN
.....
END
This is one of the example of firing the trigger

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.