question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why is the SqlDependency object unable to detect the changes in SQL Server table?

See original GitHub issue

It’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:closed
  • Created 5 years ago
  • Comments:27 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
christiandelbiancocommented, Jul 28, 2018

I need a copy of your database. Can you remove all tables present in it and send me?

0reactions
christiandelbiancocommented, Sep 12, 2019

Hi @petrosmm can you refresh my brain about this topic? Sorry but i cannot remember everything, expecialy if i work on different projects. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Why is the SqlDependency object unable to detect ...
I am using the SqlTableDependency nuget package to get notifications if a particular table's cell gets modified. I have enabled the service ...
Read more >
Detecting Changes with SqlDependency - ADO.NET
A SqlDependency object can be associated with a SqlCommand in order to detect when query results differ from those originally retrieved.
Read more >
SqlDependency.Start() fails due to seeming cross domain ...
I've started using the SQL Server Service Broker services to detect changes in a SQL table. The .NET Framework has the SqlDependency class ......
Read more >
SqlDependency performance - SQL Service Broker forum
I'm using SqlDependency (sql server 2008 r2) to get notification when data in some tables changes. The query notification is for cache invalidation....
Read more >
SignalR Core and SqlTableDependency - Part Two
In a few words SqlDependency is a SQL Server API to detect changes and push data from data base and it's based on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found