How can i call a Trigger in ASP.NET ?

R

Ricardo Corsi

Hi,

It is possible to call a trigger (inside a sql server..) with asp.net ? how
can i do that ?
thks!
 
S

Shan Plourde

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
 
R

Ross Jones

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.
 
T

Thomas Dodds

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top