Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-04-02
6
Medium Priority
?
453 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:reddal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 24050250
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?
0
 
LVL 16

Expert Comment

by:Auric1983
ID: 24050281
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"
0
 
LVL 19

Accepted Solution

by:
elimesika earned 1000 total points
ID: 24050367
HI

You will have to upgrade at least to .NET 2.0 to use CLR SP
http://msdn.microsoft.com/en-us/library/5czye81z(VS.80).aspx

or to use SqlCacheDependency (also .NET 2.0)
http://davidhayden.com/blog/dave/archive/2006/04/30/2930.aspx

on 1.1 , as far as I know , polling is the only answer...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:reddal
ID: 24050371
> 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
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 1000 total points
ID: 24050399
>>Do you know if there is a .NET 1.1 solution?

I don't know any other easy way (other then polling the database every x seconds).
0
 

Author Closing Comment

by:reddal
ID: 31565793
Thanks - you saved me a lot of wasted time trying to find a solution that doesn't exist.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question