1

I currently have a datagridview in .net that is connected by to a SQL database. The datagridview shows sales orders. New sales orders go on all the time and we'll have dozens of clients viewing the datagrid application.

I would like the application to seemlessly update when a new sales order goes on without the user having to click refresh everytime.

My thought is: Create a separate thread that on an interval queries the database, generates a dataset and compares it with the original. If its different it will invoke an event that will cause the datagridview to update.

My worry is: if i have dozens of users all running a background thread constantly querying the database on an interval, am I not creating lots of work for the SQL server? Is this the right way to do it?

Any advice would be appreciated.

(Using VB.net, SQL 2008)

rmon2852
  • 220
  • 1
  • 7
  • 19
  • I've found this that I am now investigating: http://stackoverflow.com/questions/19008396/display-data-table-sql-realtime-in-datagridview – rmon2852 May 29 '15 at 08:00
  • 1
    DataSets are not thread safe, so you almost certainly don't want to attempt a multithreaded solution. – Joe May 29 '15 at 09:03

1 Answers1

0

The answer is related to investigating SQLDependancy to monitor database changes and then asynchronously updating the datagrid.

The following post lead me to the answer for any concerned: http://www.dreamincode.net/forums/topic/185244-using-sqldependency-to-monitor-sql-database-changes/

rmon2852
  • 220
  • 1
  • 7
  • 19