Watcher for Datasets?

  • Thread starter Thread starter J Rico
  • Start date Start date
J

J Rico

Hi,
I'm making an App in which a form is bounded to a table in a database,
and with some arrow keys, you can move through the rows of the
database.
At the moment I do a request to the database each time an arrow is
clicked, but my idea is to load an entire dataset when the form is
loaded and not having to make requests to the database all time.
The problem is that if I do it this way, if other uses introduces a new
row in the database, it won't show on the form I have opened. I'm
wondering if there's something like filesystemwatchers but for
databases, so I only have to reload the dataset if something has
changed in the database.
Thanks in advance.
 
¤ Hi,
¤ I'm making an App in which a form is bounded to a table in a database,
¤ and with some arrow keys, you can move through the rows of the
¤ database.
¤ At the moment I do a request to the database each time an arrow is
¤ clicked, but my idea is to load an entire dataset when the form is
¤ loaded and not having to make requests to the database all time.
¤ The problem is that if I do it this way, if other uses introduces a new
¤ row in the database, it won't show on the form I have opened. I'm
¤ wondering if there's something like filesystemwatchers but for
¤ databases, so I only have to reload the dataset if something has
¤ changed in the database.
¤ Thanks in advance.

DataSets are essentially disconnected so the only way to avoid latent data is to periodically query
the database and re-populate the controls containing the data on your Form.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Not really .. but you can easily cook up one on your own using the various
other events available such as TableNewRow etc.
 
"Sahil Malik [MVP]"
Not really .. but you can easily cook up one on your own using the various
other events available such as TableNewRow etc.
To see if a database change has occured? Can you enlighten us how?

Cor
 
AHA .. it helps to read the full question huh?

Well, there is SqlDependency for this very purpose, but a database pinging
the client == not scaleable architecture, because essentially you are
overloading the database in that regard. In .NET 1.1 you can use an extended
stored proc to touch a file, and then put a filedependency on that.

Based on these you could reload your dataset.

But a better solution would be to not reload the dataset, and instead simply
use optimistic concurrency models to prevent the issues you are running
into.


- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
 
Sahil Malik said:
AHA .. it helps to read the full question huh?

Well, in ADO.NET 2.0
there is SqlDependency for this very purpose, but a database pinging
the client == not scaleable architecture, because essentially you are
overloading the database in that regard.

Two things. SqlDependency is not really a scalability problem, Sevice
Broker can process a whole lot of query notifications.

But having the database server establish a connection to the the client
won't work in many network configurations.

Using SqlNotificationRequest is often a better option, as it allows you to
process the query notification over a normal SqlConnection.

David
 
Thanks for the replies, I'll try different solutions to see which one
is better for our customer.

Jordi
 
Back
Top