Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL-Server DataGrid
Hello all,
 
So I have the following dataflow :
SQL SERVER Table A > C# Observable collection > XAML Binding
 
I know that obsverable collection implements already PropertyChange so the
C# Observable collection > XAML Binding part is not an issue.
 
My question is : Is it possible to update the collection when I change a value in the sql table ?
Posted 9-Dec-11 7:20am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You will need a to update the underlying datasource everytime the table changes.
Have a look at event based processing[^].
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

So I dug into the question, but even if this solution propose interesting features, it doesn't suit my needs.
It's more like a monitoring method that I need.
In here, every change in the table will trigger the event base processing and send me a notification once. But say I have multiple instance of a programs taht connects to this database, if one instance updates the table, then it won't be catch by the other instances.
 
I ll keep you posted if I find an answer, thanks though
  Permalink  
Comments
Amir Mahfoozi at 10-Dec-11 1:12am
   
I think saving the changes and notifying all clients of the happened changes, are two distinct problems.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Ok, after more research I found out that there is something called SqlDependency that was implemented since SQL server 2005.
Very interesting function that enables the SQL Server to "push notifications" to the subscriber. (where here the subscriber is my C# program)
 
So now whenever the table in SQL change or is modified then it triggers a function in my C# program.
 
Pretty Cool Smile | :)
 
Thanks Abhinav for the hint. It helped me finding that.
  Permalink  
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 545
1 Kornfeld Eliyahu Peter 407
2 Maciej Los 369
3 DamithSL 221
4 OriginalGriff 218
0 OriginalGriff 6,383
1 DamithSL 4,879
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,056
4 Sergey Alexandrovich Kryukov 3,927


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 12 Dec 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100