0

I have a desktop application running on multiple PCs. When I insert a new record, how to update other client's file_Id C# SQL Server textbox? Is there any method or trigger that SQL Server notifies the client of any data that has changed?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
waleed
  • 1
  • 1
  • You could use [SqlDependency](https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql/detecting-changes-with-sqldependency) as long as you don't have many clients. It's asynchronous but the latency is typically sub-second. Here's [an example](https://stackoverflow.com/questions/41075211/sqldependency-doesnt-fire-onchange-event-when-dataset-is-changed). – Dan Guzman Jun 12 '22 at 12:17
  • Does this answer your question? [Is there a way to be notified in .NET when data changes in the Sql Server? Like an Event?](https://stackoverflow.com/questions/12353225/is-there-a-way-to-be-notified-in-net-when-data-changes-in-the-sql-server-like) – SMor Jun 12 '22 at 12:45
  • @DanGuzman what about peformance if i have more than 200 client or more (sql server) – waleed Jun 12 '22 at 13:01
  • Performance will depend on both the number of clients and the frequency of updates. See [this article](https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms187528(v=sql.105)). You'll need to [race your horses](https://ericlippert.com/2012/12/17/performance-rant/) for your environment and workload but I suggest a shared rest service with SqlDependency where clients use a long-polling technique to get notified of changes. – Dan Guzman Jun 12 '22 at 13:44

1 Answers1

0

There is no such thing, you might wanna check the tables on an interval of let's say 2 seconds. SQLs are a protocol for storing data, not data communication.

Saylent
  • 119
  • 7
  • you mean make timer to check if total row of File_id is greater ->then load new record(File_id) ? – waleed Jun 12 '22 at 11:28