Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I have difficulty to pushing data in realtime to the client web from SQL server 2008!
perhaps if someone have experiance with this and can give me some tips what way is better and if there is an example of that will be appreciated!
I tried sveral way such as signalR! but I am not so expert in that!
so what I have is a table in database (SQL server 2008) and ASP.NET Web Application
I need to publish data in realtime to WEBForm in realtime
for example if the database get new record it Shows in the webform strat awayز

thanks you so much!
Posted

Websites are not realtime. The best you can do, is an AJAX call on a timer and refresh data regularly. The more often you make that call, the more work your DB has to do, regardless of if the data changes.
 
Share this answer
 
Comments
Mo Kash 3-Jun-13 9:44am    
Thanks Christian,
that is really helpfull, I was not sure to use signalR or ajax.
but I really appreciate if there is any example for dynamic form with ajax and asp.net 4.5

thanks
Dylan Morley 3-Jun-13 10:08am    
With libraries such as Node JS and Signal R, not sure if I agree with that Christian. I guess you can say we can't do it consistently across all browsers yet (Signal R will have to fallback to polling if sockets not supported, nice article from Hanselman here http://www.hanselman.com/blog/YourUsersDontCareIfYouUseWebSockets.aspx)
You could achieve this with an SQL Dependency and Signal R. Whenever a new record is entered into the table, the dependency would trigger an event that you could catch and then forward on to your Signal R hub.

Have a go of Signal R, it's possibly the simpliest thing I've ever worked with to get up and running quickly!

Have a look at the documentation (you'll be able to get something running if you follow this)
https://github.com/SignalR/SignalR/wiki/QuickStart-Hubs[^]

...and an article from Scott
http://www.hanselman.com/blog/AsynchronousScalableWebApplicationsWithRealtimePersistentLongrunningConnectionsWithSignalR.aspx[^]


If you control all of the code (e.g. the code that is putting data into your SQL table) then you can intercept at this point and just send a message to your Hub and you wouldn't need an SQL Dependency.
 
Share this answer
 
Comments
Mo Kash 3-Jun-13 10:38am    
I thought about signalR and I try it and I got this error which I couldn't solve

0x800a138f - JavaScript runtime error: Unable to get property 'client' of undefined or null reference
in this line
lm.client.displayStatus = function () {
getData();
};
Mo Kash 3-Jun-13 10:41am    
the problem is lm are undefined which I don't know why from this line
var lm = $.connection.myHub;
I am using these as reference as well
<script src="Scripts/jquery-2.0.1.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.signalR-1.1.2.min.js" type="text/javascript"></script>
<script src="~/signalr/hubs" type="text/javascript"></script>
Mo Kash 3-Jun-13 10:57am    
I track it down and I think the compiler dose not execute MyHub. for some reason I hope if some one have any suggestion or any idea how to solve this or where I should check! is it a bug in signalR???
I solve the problem It is working now with signalR, thanks for all of you guys!
the problem was I didn't refer to the script library in the right way.


Thanks for all, and I would like to have example how I can do that with ajax only using timer, since I am not sure how much efficient signalR with lot's of clients and data! if anyone have more information about that plz send me a link!
/Mo
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900