473,395 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

SQL trigger -> C# program

Hello,

I'm using VS2005 and SQL 2005.

Is it possible for a SQL trigger to immediately raise an event in my C#
program?
Actually it's C++/CLI, but it's easy to translate C# -C++/CLI, so any help
will be appreciate.
My program reads rows from database when some column ("Row sent") in these
rows has value of false.
I have to do this as fast as possible, but I don't know any _quick_ way to
find out if any row has value of false
in the specific column.
As far as I know there are a few ways to do this :
1) constantly asking database with select statement
2) SQL Notification Services
3) SQL trigger (INSERT/UPDATE) :
a) connects to my program (listening on TCP/IP port) and gives
information about column changed
b) writes Event to EventViewer (EventLog class), while my program has
OnEntryWritten function (EntryWrittenEventArgs Class)
c) ?

These methods are slow :/ Do you know anything better ?

Thx.
Gregi

Jul 21 '06 #1
1 6754

"Gregi" <gr**@wXkXngs.plwrote in message
news:e9**********@nemesis.news.tpi.pl...
Hello,

I'm using VS2005 and SQL 2005.

Is it possible for a SQL trigger to immediately raise an event in my C#
program?
Actually it's C++/CLI, but it's easy to translate C# -C++/CLI, so any
help
will be appreciate.
My program reads rows from database when some column ("Row sent") in these
rows has value of false.
I have to do this as fast as possible, but I don't know any _quick_ way to
find out if any row has value of false
in the specific column.
As far as I know there are a few ways to do this :
1) constantly asking database with select statement
2) SQL Notification Services
3) SQL trigger (INSERT/UPDATE) :
a) connects to my program (listening on TCP/IP port) and gives
information about column changed
b) writes Event to EventViewer (EventLog class), while my program has
OnEntryWritten function (EntryWrittenEventArgs Class)
c) ?

These methods are slow :/ Do you know anything better ?
Yes. SQL 2005 and .NET 2.0 support query notifications and in-database
queuing with Service Broker.

Using SqlDependency to Subscribe to Query Notifications
http://msdn2.microsoft.com/en-us/library/ms179575.aspx

Using SqlNotificationRequest to Subscribe to Query Notifications
http://msdn2.microsoft.com/en-us/library/ms190270.aspx

This is all built on SQL Server Service Broker, which you can use directly
to to queueing and notification in the database. SO instead of a query
notification you could use a trigger to drop a message in a queue, and have
your external C++/CLI or C# program immediately pick up the queued message.

Service Broker Programming
http://msdn2.microsoft.com/en-us/library/ms171562.aspx

David
Jul 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dunc | last post by:
I'm new to Postgres, and getting nowhere with a PL/Perl trigger that I'm trying to write - hopefully, someone can give me some insight into what I'm doing wrong. My trigger is designed to reformat...
1
by: Matik | last post by:
Hello to all, I have a small question. I call the SP outer the DB. The procedure deletes some record in table T1. The table T1 has a trigger after delete. This is very importand for me, that...
6
by: Scott CM | last post by:
I have a multi-part question regarding trigger performance. First of all, is there performance gain from issuing the following within a trigger: SELECT PrimaryKeyColumn FROM INSERTED opposed...
6
by: Mary | last post by:
We are developing a DB2 V7 z/OS application which uses a "trigger" table containing numerous triggers - each of which is activated by an UPDATE to a different column of this "trigger" table. When...
6
by: JohnO | last post by:
Hi Folks, I have an update trigger that fails (it inserts an audit table record) in some circumstances. This is causing the triggering transaction to fail and roll back. Is there any way to...
0
by: JohnO | last post by:
Thanks to Serge and MarkB for recent tips and suggestions. Ive rolled together a few stored procedures to assist with creating audit triggers automagically. Hope someone finds this as useful as...
5
by: Bob Stearns | last post by:
I have two (actually many) dates in a table I want to validate on insertion. The following works in the case of only one WHEN clause but fails with two (or more), with the (improper?...
1
by: deepdata | last post by:
Hi, I am creating a trigger in DB2 express version. When i use the following syntax to create trigger CREATE TRIGGER USER_PK_TRIGGER BEFORE INSERT On users REFERENCING NEW As N FOR EACH...
9
by: Ots | last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app. I have an Audit trigger that logs changes to tables. I want to apply this trigger to many different tables. It's the same trigger,...
7
by: Shane | last post by:
I have been instructed to write a trigger that effectively acts as a foreign key. The point (I think) is to get me used to writing triggers that dont use the primary key(s) I have created the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.