How can i call a Trigger in ASP.NET ?

  • Thread starter Thread starter Ricardo Corsi
  • Start date Start date
R

Ricardo Corsi

Hi,

It is possible to call a trigger (inside a sql server..) with asp.net ? how
can i do that ?
thks!
 
Triggers are not like stored procedures or functions. Normally you can
decompose your trigger logic into 2 items, 1 being the trigger, the
other being a stored procedure that the trigger can then call. This way,
you can also call the stored procedure from ASP.NET.

If that is not possible, a kludge is to issue a SQL statement that will
fire the trigger. For example, if you have an update trigger on column
XYZ, then if you issue an UPDATE table SET XYZ = XYZ (dummy SQL
statement to force trigger fire), that should do it, but I wouldn't
recommend it over the first option.
Shan
 
No, you can't.

You can however perform a SQL statement or Stored Procedure that will modify
a table and force the trigger to run.

HTH.
 
Ricardo,

I would think that due to the nature of triggers you would have to make an
effect on te table to have the trigger run ... if the code you have is in a
trigger, and you need it outside the trigger too, then put the common code
in a procedure or function and call it from your ASP.NET & your trigger.
 
Back
Top