Search code examples
c#sql.netsql-serverquery-notifications

SqlDependency when SQL Server stops


I am using SqlDependency to get change notifications from SQL Server. If the SQL Server is restarted, the notifications are resumed with it, but if SQL Server is stopped and then started then it looses the dependency.

Is this the expected behavior?

If yes then how can I know if the SqlDependency is stopped and I need to re-register the dependency. SqlNotificationInfo doesn't provide any information regarding it.


Solution

  • Well, as of know as a workaround, I have added a refresh button to my application. So if user thinks that he is detached from SQL Server, he can refresh and re-register the dependency.

    But still, user will be unaware for how long he is detached to SQL Server and just do try-and-error with refreshes.