Solved

SignalR - getting new data from sql DB

Posted on 2016-10-25
5
65 Views
Last Modified: 2016-11-09
Im looking at SignalR, however i'm a little confused about how it will update based on new data

I have a sql server 2014 enterprise table called tblAssets
On this table is a column called LatestRecordId

This contains the latest ID from a table called tblAssetLogs

Currently, every 30 seconds I use long polling to get the latest asset log data.

What i want to do:
1. every time tblAssets.LatestRecordId is changed, then push the new data to the client

Does anyone know if this is possible? and how i would achieve this?

I'm using .net framework 4.5 and iis7 on windows 2008 r2
0
Comment
Question by:websss
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:Nakul Vachhrajani
ID: 41858574
Based on your requirement, it seems that you need transactional replication between the Assets database (article to replicate would be based on the data to be exchanged with the client) and the client database.
0
 

Author Comment

by:websss
ID: 41858581
I'm not sure what that means
But in a nutshell
When an ASSET sends new data to the server, we insert it into the LOG table, and then use the newly inserted records ID to update the ASSETS table (tblAssets.LatestRecordId)

When this ID changes, it needs to push to the client as the data needs to be refreshed on their browser

how do we do that?
0
 
LVL 11

Expert Comment

by:Nakul Vachhrajani
ID: 41858689
Oh, refreshed on the browser application. I thought it was to be sent over to another database/database system. Sorry.

You can have a ROWVERSION column on your dbo.tblAssets tables. This data should be stored in your session. What you need is a process on the client side that regularly polls the database for changes by checking to see if the ROWVERSION has changed (it will automatically change when you update the data in the table), and if a change is detected, refresh the UI.

Database systems, unlike front-end applications do not have the ability to "fire" a message - they are data storage and processing areas and once processed, the requesting application has to pick up the data (like a kitchen, for example - an order comes in, it is serviced and then the banquet staff must periodically check and pick it up if the meal is ready).
0
 

Author Comment

by:websss
ID: 41858696
hmmm
this is long polling, and i do this already
Kinda outdated now
0
 
LVL 11

Accepted Solution

by:
Nakul Vachhrajani earned 500 total points
ID: 41858719
If you use Service Broker (available on Enterprise & Standard only), you may want to explore using Query Notifications: http://www.codeproject.com/Articles/144344/Query-Notification-using-SqlDependency-and-SqlCach
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now