sqldependency

SQL Dependency on SQL Server 2008 Express

时光毁灭记忆、已成空白 提交于 2019-12-03 20:57:53
I have an application which successfully uses SqlDependency with SQL Server 2008 Standard Edition. But if I switch the connection string to SQL Server 2008 express (with enabled Broker) it stops working. I'm not sure whether it is SQL Server Express specific, but which steps should I follow to find out the reason of the problem? Update. By "stops working" I mean notifications are not raised by SqlDependency Remus Rusanu To understand how SQL Dependency works I recommend you read The Mysterious Notification . To troubleshoot it follow the normal Troubleshooting Dialogs steps. The typical

SqlDependency subscription not dropped from dm_qn_subscriptions on shutdown

雨燕双飞 提交于 2019-12-03 08:35:14
My SqlDependency works fine, and the Broker Queue and Service get dropped properly when the application exists (I do execute SqlDependency.Stop(...) as recommended before terminating the process), yet I notice that the notification subscription created by the SqlDependency lives on in the table "sys.dm_qn_subscriptions" after the application shuts down. If I later (post-app shutdown) execute the condition that ought to make this subscription fire, it does seem to fire, as SQL Server logs an Info message in Event Viewer to the effect that: The query notification dialog on conversation handle '

SQL Server Notifications - My OnChange does not fire

纵然是瞬间 提交于 2019-12-03 08:32:32
I would like to make use of SQL Server notifications to capture insert events at my database within a winforms app. I am attempting to use the SQLDependency object. The MSDN articles make this seem pretty straight forward. So I have created a little example application to give it a try. The event only seems to fire as I enter my application the first time(MessageBox appears). Inserting data into the table does not raise the OnChange event it would seem. Can someone tell me what I'm missing? Thanks! public Main() { InitializeComponent(); var check = EnoughPermission(); SqlDependency.Stop(constr

SQL Dependency in C#

时光怂恿深爱的人放手 提交于 2019-11-30 22:53:45
I'm trying to figure out how to use SQL Dependency (C# 4.0) to 'listen' for changes to a database. I've seen quite a few things on the web, but they seem to be tailored (naturally) for using the dependency to pull the same data that the SQL Dependency is dependent on. For example, this article . What I'm trying to do is create a dependency that, when triggered, results in a number of different SQL 'Select' queries (which I can store in other methods etc). For example: I'm trying to set a dependency that watches the number of rows in table. When the number of rows increases, then do x, y, z (ie

SQL Dependency in C#

蓝咒 提交于 2019-11-30 17:26:38
问题 I'm trying to figure out how to use SQL Dependency (C# 4.0) to 'listen' for changes to a database. I've seen quite a few things on the web, but they seem to be tailored (naturally) for using the dependency to pull the same data that the SQL Dependency is dependent on. For example, this article. What I'm trying to do is create a dependency that, when triggered, results in a number of different SQL 'Select' queries (which I can store in other methods etc). For example: I'm trying to set a

Getting data from SqlDependency

可紊 提交于 2019-11-30 15:05:51
问题 I've got a table and a SqlDependency that is waiting for new inserts. OnChange fires as I need, but I don't understand if it's possible to get the row which cause the databse change. SqlDependency sql command: SqlCommand cmd = new SqlCommand("SELECT id FROM dbo.DataRequests", m_sqlConn); OnChange code: private void OnChange(object sender, SqlNotificationEventArgs e) { SqlDependency dependency = sender as SqlDependency; dependency.OnChange -= OnChange; Console.WriteLine("Info: " + e.Info

SqlDependency error after a long time

穿精又带淫゛_ 提交于 2019-11-30 13:49:04
I got a windows service listening to inserts in a table using the SqlDependency class. It works fine for several days but then suddenly stops working. In the normal scenario I receive change events e.Type = SqlNotificationType. Change e.Info = SqlNotificationInfo. Insert e.Source = SqlNotificationSource. Data If nothing changes I get timeout events every 3600 seconds e.Type = SqlNotificationType. Change e.Info = SqlNotificationInfo. Error e.Source = SqlNotificationSource. Timeout or (don't know why there are two different timeout events) e.Type = SqlNotificationType. Change e.Info =

SqlDependency with EntityFramework 6 (async)

雨燕双飞 提交于 2019-11-30 05:12:07
I'm using the EF 6 async querying features, such as var list = await cx.Clients.Where(c => c.FirstName.Length > 0).ToListAsync(); I want to also start SQL dependencies on these queries so that I can get notified when the data in the database changes. I can do this using the System.Runtime.Remoting.Messaging.CallContext as follows: async Task GetData() { using (ClientsContext context = new ClientsContext()) // subclass of DbContext { SqlDependency.Start(context.Database.Connection.ConnectionString); SqlDependency dependency = new SqlDependency(); dependency.OnChange += (sender, e) => { Console

SqlDependency Reliablity?

 ̄綄美尐妖づ 提交于 2019-11-29 20:46:14
My current situation is that I have an application that needs to be notified when new data arrives in a database table. The data is coming from an external source (that I have no control over--this is this only integration option). When new data arrives, my application needs to take certain actions--basically query for the new data, handle it, insert the result into a local table, etc. I want to avoid polling if possible, as the data is expected to be handled in real time. That said, making sure no data ever gets missed is the #1 priority. My questions: Is SqlDependency generally considered

SqlDependency error after a long time

大兔子大兔子 提交于 2019-11-29 19:14:14
问题 I got a windows service listening to inserts in a table using the SqlDependency class. It works fine for several days but then suddenly stops working. In the normal scenario I receive change events e.Type = SqlNotificationType. Change e.Info = SqlNotificationInfo. Insert e.Source = SqlNotificationSource. Data If nothing changes I get timeout events every 3600 seconds e.Type = SqlNotificationType. Change e.Info = SqlNotificationInfo. Error e.Source = SqlNotificationSource. Timeout or (don't