Solved

SignalR - getting new data from sql DB

Posted on 2016-10-25
5
79 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 12

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 12

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 12

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

911 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

24 Experts available now in Live!

Get 1:1 Help Now