Why is the SqlDependency object unable to detect the changes in SQL Server table?
See original GitHub issueIt’s been 3 days that I have been trying to achieve this but couldn’t.
I am using the SqlTableDependency nuget package to get notifications if a particular table’s cell gets modified. I have enabled the service broker.
I have taken every necessary measure. Upon starting the application it creates a trigger, queue, contract, message type automatically on the table and safely disposes upon closing the app but it never returns the results. The database user has Db_Owner role and everything but still not working. Please help me. I am frustrated and tired of this. It’s been 3 days.
I change the values in the edit mode of the table or using an update query.
I am following this link. It has all the necessary steps and also a demo video. https://github.com/christiandelbianco/monitor-table-change-with-sqltabledependency
Code:
namespace SqlDependency
{
class Users
{
public string UserName { get; set; }
public string Password { get; set; }
}
class Program
{
const string ConnectionString = @"Data Source=(local);Initial Catalog=HimHer; Integrated Security=True";
static void Main(string[] args)
{
using(var dep = new SqlTableDependency<Users>(ConnectionString) )
{
dep.OnChanged += Dep_OnChanged;
dep.Start();
Console.WriteLine("Press a key to exit");
Console.ReadKey();
dep.Stop();
}
Console.WriteLine("Waiting For Changes ..... ");
Console.ReadLine();
}
private static void Dep_OnChanged(object sender, RecordChangedEventArgs<Users> e)
{
var changedEntity = e.Entity;
Console.WriteLine("DML operation: " + e.ChangeType);
Console.WriteLine("ID: " + changedEntity.UserName);
Console.WriteLine("Name: " + changedEntity.Password);
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:27 (9 by maintainers)
Top GitHub Comments
I need a copy of your database. Can you remove all tables present in it and send me?
Hi @petrosmm can you refresh my brain about this topic? Sorry but i cannot remember everything, expecialy if i work on different projects. Thanks