0

I have an asp.net page/C#. I want check every 15 seconds the database. If there are changes, It will occur post back, if not, nothing will happen. How can I do this? Until now i am using page refress every 2 minutes, but this is not very helpfull.

<meta http-equiv="refress" content="120"/>
focus
  • 171
  • 9
  • 31
  • 1
    Show your work and tell people what have you tried exactly. – Soner Gönül Jun 04 '13 at 12:40
  • Until now i am using – focus Jun 04 '13 at 12:41
  • 1
    You could use a [**webmethod**](http://geekswithblogs.net/frankw/archive/2008/03/13/asp.net-ajax-callbacks-to-web-methods-in-aspx-pages.aspx)(similar to a webservice) to check the database, if you need the refresh [trigger `__doPostBack` from javascript](http://stackoverflow.com/questions/3591634/how-to-use-dopostback). – Tim Schmelter Jun 04 '13 at 12:46
  • How this method will be trigered every 15 sec? – focus Jun 04 '13 at 12:51
  • webmethod as @TimSchmelter said will work, use javascript setInterval method to set it up so that it calls the webmethod every 15 sec. – Paritosh Jun 04 '13 at 13:09

1 Answers1

1

do you want to track all changes in your database ?

If yes then this link is helpful How to monitor SQL Server table changes by using c#?

If you are concerned just to show new added record, you may do that with JQuery and WCF , Three are many different ways.

If it does not help will you mind to elaborate your question ?

Community
  • 1
  • 1
Rajeev Bera
  • 2,021
  • 1
  • 16
  • 30
  • Thank for your reply. I just want to check every 15 second. If there is an update on a specific database table. If there is a change the data on the the web page will be updated – focus Jun 04 '13 at 13:12
  • Then the best solution will be use SqlDependency and Query notifications to monitor SQL Server data changes. Query Notifications allow an application to be notified when data has changed in the database.here is one of the detailed article that will help. http://www.dreamincode.net/forums/topic/156991-using-sqldependency-to-monitor-sql-database-changes/ Let me know if you need any other help. – Rajeev Bera Jun 04 '13 at 13:20