How to refresh aspx page from sql server
Even though the server may be notified when data has changed, the real challenge is communicating those changes to the client in real-time without requiring a timer or user interaction.
You have a couple of options:
Your best bet is to use a WebSocket, which enables bidirectional communication between the client and server. This is the solution I would pick.
Here are some examples using
WebSockets
:- Building real-time web apps with WebSockets using IIS, ASP.NET and WCF
- HTML5 C# WebSockets Server and ASP.NET Client Implementation
- C# WebSocket Server
- WebSockets in ASP.NET 4.5
- WebHooks and WebSockets in ASP.NET
There are a few good libraries around too that will take care of most of the leg work. A couple to check out are WebSync and PokeIn. Both products offer decent documentation and community editions that you can download for free.Here are some tutorials to check out:
- WebSync Tutorials
- PokeIn Basic Tutorial / PokeIn Advanced Tutorial
Use AJAX to poll for changes every
X
number of seconds. If changes are detected reload the page, otherwise do nothing.
page refresh only when new records are inserted in database
For SQL 2005 and onwards you'd use SQL Server Query Notifications and the SqlDependency class in C#
There is a tutorial here that you can follow for SQL2005 onwards.
ASP.Net has SqlCacheDependency which is slightly different and works for earlier versions of SQL as well as current versions (it uses polling in SQL2000 and service broker in SQL2005+), but is ASP.Net specific, so you may have difficulty using it in a non web application.
SignalR notification never reload the page
The SignalR Hubs API enables you to make remote procedure calls (RPCs) from a server to connected clients and from clients to the server. In server code, you define methods that can be called by clients, and you call methods that run on the client.
In client code, you define methods that can be called from the server, and you call methods that run on the server. SignalR takes care of all of the client-to-server plumbing for you.client can call hub inherited method only.
Call BroadcastData
methods that run on the server:
hubNotify.client.BroadcastData = function () {
getAll();
};
Ref: Link
Related Topics
Convert Data from Wide Format to Long Format in Sql
Oracle Text Search on Multiple Tables and Joins
Sql Select Distinct Substring Where Like Muddleup Howto
Insert Binary File into Mssql Db (Varbinary) with Python Pymssql
How to Call C# Function in Stored Procedure
Sql Server - Filter Field Contents to Numbers Only
How to Expand Out a Row into Multiple Row Result Set
How to Create Trigger to Keep Track of Last Changed Data
Update All SQL Null Values in Multiple Columns Using Column Level Where Clause
How to Add Minutes to The Time Part of Datetime
How to Add an Identity Column to an Existing Database Table Which Has Large Number of Rows
How to Add a Not Null Constraint on Column Containing Null Values
Row Locks - Manually Using Them
Sql Server Reverse Order After Using Desc
Automatically Create Scripts for All SQL Server Jobs
Can a Stored Procedure Work with Two Different Databases? How About Two Servers