Link to home
Start Free TrialLog in
Avatar of reddal
reddal

asked on

How to receive a notification of a data change in c# from SQL Server 2005?

Hi,

I have a .NET (v1.1) c# console application that accesses data in an SQL Server 2005 database, via SQL.

I want to have a mechanism to receive a notification (event? trigger?) when something changes in a given table so I can reload it. Whats the easiest way to code that? Obviously I could just poll or something like that - but I'm sure there will be a nice solution supported by my combination of .NET 1.1 SQLConnection classes and SQL Server 2005 backend.

Whats the best/easiest way to achieve that?

thanks - reddal

Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

using ADO.Net 2.0 and SQL 2005, you can use the notification: http://msdn.microsoft.com/en-us/library/ms379594.aspx

can you migrate to .Net 2.0?
Create a second table with the following columns

Tablename (varchar) , lastupdated (datetime), complete (bit)

You could create a SQL update trigger
on the table you want to monitor to insert
a record into the "monitor table" with the name of the table, the date/time of the update and set the complete field to 0

You'd then be able to query that monitoring table for "action required"
ASKER CERTIFIED SOLUTION
Avatar of elimesika
elimesika
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of reddal
reddal

ASKER

> emoreau: can you migrate to .Net 2.0?

Yes that is planned (to 3.5 in fact) - but not immediately. Do you know if there is a .NET 1.1 solution?

> Auric1983:

I would still have to poll the monitoring table at regular intervals using your solution I think? I'm hoping to find a way to avoid that.

- reddal
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of reddal

ASKER

Thanks - you saved me a lot of wasted time trying to find a solution that doesn't exist.