Sunday, September 17, 2006

2 simple steps to enable notifications from SQL 2005 to ASP.net 2.0

2 simple steps to enable notifications from SQL 2005 to ASP.net. This uses Broker service provided only in SQL 2005. Broker service is not available in SQL 2000.

A> Change the SQLDependency from your DB:table name to CommandNotification
B> And in the Global.asax file under Application_Start event start the SQL Dependancy. That's it!

System.Data.SQLClient.SQLDependancy.Start(ConnectionString)

1> NO POLLING FROM THE ASP.net runtime
2> AVOIDS DATABASE TRIPS UNNECESSARILY
3> SQL SERVER 2005 automatically sends notification whenever there is change in the data (at table level)
4> SILENT communication between SQL engine and .net runtime
5> Performance benefit compared to ASP.net polling

Note: You need to have SQLCacheDependancy enabled = True in web.config file
...




...


Cheers - DJ

No comments: