Detecting changes in a database

  • Thread starter Thread starter Dom
  • Start date Start date
D

Dom

I have a program used by many people. Each person makes changes in a
database. I would like to have all the users see these changes soon
after they are made.

Is there some way to do this in CSharp?

Ideally, I would like something like:


SetWatchPoint (Database, Table, CallbackRoutine)

CallbackRoutine ()
{
[Code to handle the changes]
[For example, add new records to a listbox]
}

Thanks a lot,
Dom
 
I have a program used by many people.  Each person makes changes in a
database.  I would like to have all the users see these changes soon
after they are made.

Is there some way to do this in CSharp?

Ideally, I would like something like:

SetWatchPoint (Database, Table, CallbackRoutine)

CallbackRoutine ()
{
   [Code to handle the changes]
   [For example, add new records to a listbox]

}

Not sure if this is the answer, but you might try looking into the
SqlDependency class.
 
I have a program used by many people.  Each person makes changes in a
database.  I would like to have all the users see these changes soon
after they are made.
Is there some way to do this in CSharp?
Ideally, I would like something like:
SetWatchPoint (Database, Table, CallbackRoutine)
CallbackRoutine ()
{
   [Code to handle the changes]
   [For example, add new records to a listbox]

Not sure if this is the answer, but you might try looking into the
SqlDependency class.- Hide quoted text -

- Show quoted text -

Thanks. It certainly looks right. have you ever used it? If so can
you give me a mockup of some code?

Dom
 
I have a program used by many people.  Each person makes changes ina
database.  I would like to have all the users see these changes soon
after they are made.
Is there some way to do this in CSharp?
Ideally, I would like something like:
SetWatchPoint (Database, Table, CallbackRoutine)
CallbackRoutine ()
{
   [Code to handle the changes]
   [For example, add new records to a listbox]
}
Not sure if this is the answer, but you might try looking into the
SqlDependency class.- Hide quoted text -
- Show quoted text -

Thanks.  It certainly looks right.  have you ever used it?  If so can
you give me a mockup of some code?

Sorry, I just thought I'd check the online help and founf that after a
search on "SqlClient Namespace". Never really used it myself.

I would probaly go the simpler route and use a log table that contains
a time stamp of the latest change and check the latest entry in a
timer loop.
 
You could easily do this using nHibernate too. Implement the IInterceptor
interface then you can catch pre-write post write etc operations.
 
You could easily do this using nHibernate too. Implement the IInterceptor
interface then you can catch pre-write post write etc operations.
--
Simon Hart
Visual Developer - Device Application Development MVPhttp://www.simonrhart.com



Dom said:
I have a program used by many people.  Each person makes changes in a
database.  I would like to have all the users see these changes soon
after they are made.
Is there some way to do this in CSharp?
Ideally, I would like something like:
SetWatchPoint (Database, Table, CallbackRoutine)
CallbackRoutine ()
{
   [Code to handle the changes]
   [For example, add new records to a listbox]
}
Thanks a lot,
Dom- Hide quoted text -

- Show quoted text -

Thanks for the tip. I know nothing about Hibernate. Can you point me
to some classes, or an article? If not, Jowcoll1 had the best
suggestion.

Dom
 
nHibernate is an ORM. I don't know you're requirements. nHibernate aould
replace pretty much your whole data acess layer if used. Checkout
hibernate.org.
--
Simon Hart
Visual Developer - Device Application Development MVP
http://www.simonrhart.com


Dom said:
You could easily do this using nHibernate too. Implement the IInterceptor
interface then you can catch pre-write post write etc operations.
--
Simon Hart
Visual Developer - Device Application Development MVPhttp://www.simonrhart.com



Dom said:
I have a program used by many people. Each person makes changes in a
database. I would like to have all the users see these changes soon
after they are made.
Is there some way to do this in CSharp?
Ideally, I would like something like:
SetWatchPoint (Database, Table, CallbackRoutine)
CallbackRoutine ()
{
[Code to handle the changes]
[For example, add new records to a listbox]
}
Thanks a lot,
Dom- Hide quoted text -

- Show quoted text -

Thanks for the tip. I know nothing about Hibernate. Can you point me
to some classes, or an article? If not, Jowcoll1 had the best
suggestion.

Dom
 
Simon said:
You could easily do this using nHibernate too. Implement the IInterceptor
interface then you can catch pre-write post write etc operations.

But that is for changes made via NHibernate within the same
process or ??

Arne
 
Notifications is the way to go if you are using any recentish SQL Server
product.

This is ish how the old version worked.

Add a triger to your table that updates a table specifically created to hold
a datetimestamp for that table, on insert, update and delete.

Poll this table (background task) for the datetime stamp of the table you
want to identify if changes have been made to. Of course this is not very
granular.

Add a datetimestamp to each row to catch updates on a more granular level.
To catch deletes on a more granular level you need to implement a
datearchived type flag rather than deleting records.
 
Back
Top