Question!!! Who can give me a hand?

As we know the DataSet is working with disconnected Data. Once we fetch the results of a query into a DataSet using a DataAdatper object. there is no longer a connection between DataSet and Database. If other user modify data in database that corresponds to the data in DataSet , we will not see those charges in our DataSet.

But in a Bussiness windows Application System. it need to responds any changes.

For example, if Sales department Manager queries the data from Databas and fills it into DataSet. Maybe there are 10 records in DataSet, But at the same time the Sales department Sales cancel a customer orders , how colud the Manager know the change ? Because the DataSet is disconnected, he will never know the changes except he close the Application and re-open it.

Is it right?If it is right, it will make a big trouble.


 




Answer this question

Question!!! Who can give me a hand?

  • Jared Parsons MSFT

    But how could i implement the program as you said.

    Do you have any sample?

  • lugi

    There's no need to close the application, you can just load the data again, using the same adapter. There are several methods to reload the data:
    You can use a timer to check the data regularly. Depending on how often the database changes, set the interval to make a trade-off between performance and up-to-date data.
    If you're using SQL Server, you can write a stored procedure that writes to a special file when data has changed, and use a FileSystemWatcher in your application to monitor that file. Once that file has changed, you know you have to reload the data.
    You can also use Notification Services with SQL Server, where your application receives an event from the SQL Server directly.

  • Question!!! Who can give me a hand?