Can a SQL trigger raise an event in C#?

G

Guest

Hello,

I'm using VS2003 and SQL 2000.

Is it possible for a SQL trigger to raise an event in my C# program?

Thx.
Andy Jacobs
 
R

Robbe Morris [C# MVP]

Why would you want to do this?

If you want events raised, something in your
C# app should trigger that, not the database.

SQL Server really doesn't have any knowledge
or the memory address to try and hook into
regarding your C# application.

Can you expand on why you would want the
database to trigger something in your app that
couldn't be triggered by the app itself?
 
M

ManniAT

I agree to Robbe,

but if there is a need a lot of ways are possible.
The simpliest approach (from my point of view) would be a call to an extended stored procedure.
This enables you to run native code which means you can do all you want:
Start a process, communicate with a service (which in fact could be you C# application) and so on.

Another simple approach could be to write a log entry.
And in your C# app you use an event watcher checking for that entry.
This last approach seems the easiest - and you have less dependicies as with an extended stored procedure.
So your trigger can stay fast - and as an isolated task the C# app reacts to the event log entry.
If you don't have to finish your C# task while in the trigger this could avoid a lot of timing (and other related) problems.

HTH

Manfred
 

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

Top