Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Application to know database update

My web application (ASP.NET 4) connects to a database (SQL Server 2005). For every new row inserted in a certain table, I want the web app can do some process (like send an email to me with new data).

How do I implement the system? My first though is having web app check the table SN column, and have a variable lastProcessedSN. And keep polling every minute. Is it possible to have DB notify web app when there's a new row being inserted?

Please advise, thanks.



EDIT: Sending an email is just an example, not the exact thing I want to do. So this question is focusing on how to implement the trigger on MSSQL table insert to call my program.

like image 342
Stan Avatar asked Jun 01 '11 20:06

Stan


People also ask

What is used to UPDATE the database?

The Update Database operator is used for updating an existing table in the specified SQL database. You need to have at least basic understanding of databases and database connections in order to use this operator properly.


1 Answers

you could use SqlDependency`s see

http://www.codeproject.com/KB/database/chatter.aspx

&

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldependency.aspx

like image 59
marc.d Avatar answered Oct 04 '22 23:10

marc.d