473,785 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 (EntryWrittenEv entArgs Class)
c) ?

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

Thx.
Gregi

Jul 21 '06 #1
1 6834

"Gregi" <gr**@wXkXngs.p lwrote 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 (EntryWrittenEv entArgs 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 SqlNotification Request 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
4185
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 / standardize phone numbers and it looks like this: CREATE or REPLACE FUNCTION fixphone() RETURNS trigger AS $$ $number .= $_TD->{new}{phone}; $number =~ s/(-|\.|\(|\)| )//g; $number .= substr($number,0,3) . "." .
1
2004
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 the SP will be finished ASAP, that's why, I do not want, and I do not need to wait for a trigger.
6
6557
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 to: SELECT * FROM INSERTED
6
7145
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 the triggers are fired, various other operations are performed on other tables in the database. The triggers are not created on these other tables because other programs perform updates to these tables and we do not want the triggers to fire...
6
9254
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 prevent this? If the trigger fails I still want the triggering transaction to continue. Cheers, JohnO
0
2478
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 I've found it educational. Note: - I build this for use in a JDEdwards OneWorld environment. I'm not sure how generic others find it but it should be fairly generic. - I use a C stored procedure GETJOBNAME to get some extra audit data,
5
3298
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? inappropriate?) error message: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: CREATE TRIGGER IS3.date_later_001i NO C;BEGIN-OF-STATEMENT;<space> which is interpreted as: An unexpected token "CREATE TRIGGER IS3.date_later_001i NO C" was found
1
2213
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 ROW
9
9312
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, with the exception of the table name. I could manually change the table name in the trigger and create it, over and over, but I'd like to automate this - by iterating through the collection of tables and passing the tablename to something that...
7
3315
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 following trigger create trigger chk_team on teams for insert as declare @chkCountry as char(2)
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9954
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8979
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.