1

I want to create application which update their control properties at the time of table values updated from database by another user. i find a solution by refreshing a control every second by help of timer, but it is not good i want to change after updating a values not to request every second SQL Server?

2 Answers 2

2

Basically you need to have SQL post when the table is updated. This called a push model (the opposite is a pull model which you are now doing).

You can use SqlDependency for this. See http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldependency%28v=vs.100%29.aspx

However, there is some overhead associated with a push approach. Many apps just do a query every n seconds (3 - 10) and then only update the control when the properties changed.

It really is a optimisation trade off. Is making a network request (pull model) more "expensive" than having SQL server doing the trigger and then send the update message (push model)?

Sign up to request clarification or add additional context in comments.

2 Comments

Thank You Richard Schneider it is very usefull for me making applications
Sorry there is something wrong in my project. when i try my code that is not due to this solution i forgot remove timer at the time of test. It was not working on my code so i am trying now some step may be missed i think. but i am trying your solution after stressful implementation i will accept your answer with best comments. thank you for your support @Richard
1

You can use SqlDependency for this, without polling.

Implementing SQL Server 2005 Query Notifications in C# Windows Application

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.