sqldependency

SqlDependency code listening to inserts/update in a table from windows service

时光怂恿深爱的人放手 提交于 2019-12-24 00:04:05
问题 my SqlDependency code is listening to inserts/update in a table from windows service and when i start the service then it works for next 2/3 days and after that it stopped working. here i am pasting my full code. public partial class PartIndexer : ServiceBase { static string connectionString = "MyConnection String;Pooling=true;Connect Timeout=20;"; SqlDependency dep; public PartIndexer() { InitializeComponent(); } #region OnStart protected override void OnStart(string[] args) { System.Data

How to setup SqlDependency to monitor multiple tables

人盡茶涼 提交于 2019-12-23 23:04:07
问题 I am trying to figure out how to monitor more than one table with a SqlDependency. All the examples I have found are for one table. I have multiple classes that represent a monitor for a specific table. Each time a change event is raised I stop the dependency and start a new one but that unhooks the other monitors. How do I get it to keep monitoring for multiple tables? Do I need to re-hookup all the monitors each time an event is caught? 回答1: Use AggregateCacheDependency class to setup

SQLDependency — Invalid SQL

↘锁芯ラ 提交于 2019-12-23 20:15:09
问题 Best I can tell from here, I am not breaking any rules with this query, but the change event fires constantly with an invalid status. SELECT COUNT_BIG([PK_Column]) AS RecordCount FROM [dbo].[My_Table] GROUP BY Varchar_50_Column If I do this, everything works correctly. SELECT [PK_Column] FROM [dbo].[My_Table] However, I don't want to return this much data, and SqlDependency seems to require executing the query once after each time the change event fires to set up (or reset) the subscription.

SqlDependency subscription not working when using IsolationLevel.ReadUncommitted in (unrelated?) Transaction

余生颓废 提交于 2019-12-21 20:39:03
问题 I've managed to get SqlDependency working, but only as long as I do not use IsolationLevel.ReadUncommited in what I thought was a SQL transaction unrelated to the SqlDependency. When I use IsolationLevel.ReadUncommitted in the transaction (heavily commented below) the SqlDependency subscription fails with an immediate OnChange notification of: sqlNotificationEventArgs.Info = "Isolation"; sqlNotificationEventArgs.Source = "Statement"; sqlNotificationEventArgs.Type = "Subscribe"; When I remove

SQL Server Notifications - My OnChange does not fire

老子叫甜甜 提交于 2019-12-21 03:02:11
问题 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?

How to track changes in many SQL Server databases from .NET application?

試著忘記壹切 提交于 2019-12-20 14:09:23
问题 Problem: There are a lot of different databases, which is populated by many different applications directly (without any common application layer). Data can be accessed only through SP (by policy) Task: Application needs to track changes in these databases and react in minimal time. Possible solutions: 1) Create trigger for each table in each database, which will populate one table with events. Application will watch this table through SqlDependency. 2) Watch each table in each database

Polling for database changes: SqlDependency, SignalR is Good

佐手、 提交于 2019-12-18 07:24:49
问题 it will be good if i need to show change data in db through sql dependency and signalr. suppose my transaction table often changed by many people. suppose in few second data is change many time then i like to know how notification will go to sql dependency class ? change data will be queued before sql dependency class ? sql dependency class can handle data change when huge no of traffic will do the changes ? here i was reading a article on SqlDependency & SignalR. the link is http://techbrij

SqlDependency OnChange Not Firing

こ雲淡風輕ζ 提交于 2019-12-18 04:18:40
问题 This is the first time I've ever needed to use an SqlDependency so I am hoping that its a stupid mistake I've made. The problem I'm having is that the OnChanged event doesn't fire when the sql table changes. No errors or anything just it doesn't fire. Here is the code public class SqlWatcher { private const string SqlConnectionString = "Data Source = CN-PC08\\DEV; Initial Catalog=DEP; User = sa; Password=******"; public SqlWatcher() { SqlClientPermission perm = new SqlClientPermission(System

SQLDependency_OnChange-Event fires only one single Time

旧时模样 提交于 2019-12-18 03:50:28
问题 I'm working with SQLDependency to notify me if there is a change in the Database. After Program Start-Up it works just fine. When I make a first change the Event fires. Wohoo... that's great. But if I made a second change the event doesn't fire again. I've searched all the web I think but haven't found anything about THIS Problem. Only found problems where the OnChange-Event fires in a Loop. Can anyone help me? Here a little code piece: private void GetStates() { if (!DoesUserHavePermission()

I want my database (SQL) to notify or push updates to client application

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 22:36:22
问题 I was developing this application on VB.net 2010 and SQL 2008 . I wanted the clients to be notified for updates on the db, and the application used to check the db for changes in the specified minute using a timer, which really is not efficient. I read about query notification , sqldependency , service broker , but then I read something that said they might not be efficient if I have 100 clients and I'm using query notifications to push notifications to my application. Would someone help out