Question update a database in my application without Rerun the program

pooya1072

Well-known member
Joined
Jul 5, 2012
Messages
84
Programming Experience
Beginner
hi
i have 2 program .in each other , there is a SQL database .one of these is the main program that information add or remove from it and other program only show the changes.all the changes in main program send to other program with replication that i create it before in sql server. now the problem is : when i change in main program , the other program don't show the changes at the time.if i exit the other program and run it again every thing is ok.so please tell me what can i do ? i want all the changes show at the time that main program is change.
 
There are basically two ways to handle this: pull and push. "Pull" means that the the application would need to ask the database repeatedly whether there is new data available and "push" means that the database would need to tell the application when new data becomes available. If you want the former then you would simply use a Timer to prompt a regular old query. If you want the latter then you can use the SqlDependency class.

DO NOT use SqlDependency if you have many clients working off that same database. If there's only one a perhaps a small number then that's OK. I have never used it so I have no example but I can tell you that it is not completely straightforward. At least you have something to search for now though.
 
There are basically two ways to handle this: pull and push. "Pull" means that the the application would need to ask the database repeatedly whether there is new data available and "push" means that the database would need to tell the application when new data becomes available. If you want the former then you would simply use a Timer to prompt a regular old query. If you want the latter then you can use the SqlDependency class.

DO NOT use SqlDependency if you have many clients working off that same database. If there's only one a perhaps a small number then that's OK. I have never used it so I have no example but I can tell you that it is not completely straightforward. At least you have something to search for now though.

thanks...but this is not my problem.the replication works ok . but the result on client app show only by an exit and rerun this program.would you please answer this question :
"in a program with a database , how can i check that the contents of a table in database is change.i want to use this as an event. if it is possible please show me by an example.
 
I wasn't talking about the replication. I was talking about the application. That's why I said "the application" in my previous post. I have already answered your question.
 
Back
Top