Database Change Notifications in ASP.NET (MVC) Using SignalR & SQL Dependency

Поделиться
HTML-код
  • Опубликовано: 11 сен 2018
  • Special Thanks Goes To Mr. Suranga Upul Priyadarshana.
    Source Code:
    github.com/mewanindula/Signal...
    This video shows how to real time update data grid, when make changes on table of database

Комментарии • 121

  • @tohabin5064
    @tohabin5064 3 года назад +1

    watching in 2020. as a beginner, I understand it easily! thank you, sir!

  • @satyagopalaphaneendrakumar3767
    @satyagopalaphaneendrakumar3767 3 года назад +1

    Thank you very much for this wonderful video. With your video example, I am able to work with one table in real-time. It would be great if you share or suggest any examples for multiple tables in real-time on one page.

  • @kevinandressanterohernande6534
    @kevinandressanterohernande6534 4 года назад

    Hi,
    continue with this !!! Thank you

  • @manojmadushan3502
    @manojmadushan3502 3 года назад

    Superb video...very helpful...👍

  • @salarkazazi695
    @salarkazazi695 4 года назад

    Thank you so much

  • @abubakkersiddiq432
    @abubakkersiddiq432 4 года назад

    Sir is it possible that I want to notify through a notification that database change is done? and can I connect azure database with this project ??

  • @CarlosJFlores89
    @CarlosJFlores89 4 года назад

    Excelent

  • @CarlosJFlores89
    @CarlosJFlores89 4 года назад

    Thank you

  • @zibazokaye1174
    @zibazokaye1174 7 месяцев назад

    Hello, if we want to make a condition in the query so that only the record of the given condition is shown, what should we do? That is, if the condition is dynamic, we should send a parameter.

  • @si4965
    @si4965 3 года назад

    Thankyou .

  • @nceevij
    @nceevij 3 года назад

    Does this realtime signal R works fine in Mac machine ? I am facing some issue its updating the UI fine on windows machine but when i run in Mac the page where signal R is implemented it stucks in loading state never loads, until i comment script signalr/hub

  • @kamilakarsu.
    @kamilakarsu. 2 года назад

    I run this project successfully but noticed something wrong when I inspect element on Network Tab. When every page refresh (f5) trigger multiple(Ex: 2 refresh x2 get req, 5 refresh x5 get req) GET request from server. How can I resolve this?

  • @acluantran3413
    @acluantran3413 5 лет назад +1

    i got a problem " Specified cast is not valid."
    my list here :
    var list = reader.Cast().Select(
    x => new {
    id=(long?)x["id"],
    EName=(string)x["EName"],
    DeviceName = (string)x["DeviceName"],
    Status = (bool)x["Status"],
    DateDetectedE=(DateTime)x["DateDetectedE"],
    DateFixedE = (DateTime)x["DateFixedE"],
    TimeToStart = (DateTime)x["TimeToStart"],
    TimeRun=(string)x["TimeRun"],
    ClientName=(string)x["ClientName"],
    }).ToList();
    please help
    thank in advance

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      After SqlDataReader reader = command.ExecuteReader(); this line,
      if(reader.FieldCount > 0)
      {
      var displayData = db.view_name.ToList();
      }
      Then return your displayData. Plese ignore, Cast and other things

  • @manjunathkannur2207
    @manjunathkannur2207 3 года назад

    Hi ,
    I performed all steps u explained, but there is not change after data base changes

  • @srikanthn4795
    @srikanthn4795 5 лет назад

    Can we do this with oracle database

  • @sarangpadalkar
    @sarangpadalkar 4 года назад +1

    Hi ,
    I just wanted to check if ow can i use SignalR with Azure SQL database.Is it possible to get input from multiple azure sql databases? i wan to show data on UI dashboard which will have data received form multiple azure sql server databases.Thanks in advance.

    • @mewanindula5877
      @mewanindula5877  4 года назад

      Sorry friend, Azure SQL databases doesn't allow enable brockers upto now.

  • @milankc9318
    @milankc9318 5 лет назад

    Thank you a lot , saved my life :)

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      You are welcome friend!!!

    • @MaheshPatel-ke6oe
      @MaheshPatel-ke6oe 5 лет назад +1

      @@mewanindula5877 Not workig...

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      Where the error is occures friend?

    • @MaheshPatel-ke6oe
      @MaheshPatel-ke6oe 5 лет назад +1

      Mewan Indula download your code and run after run sql query , data dose not display real time

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      Can you goto inspect of web page? and can you tell me there has any errors of console tab?

  • @mehmetkuzu9213
    @mehmetkuzu9213 4 года назад +3

    hello,how can i convert this sample using the api sending query to database by storedprocedure

    • @mewanindula5877
      @mewanindula5877  4 года назад

      SQL Dependency doesn't support for Stored procedures and Views

  • @WalterwhiteAlbuquerqueNM
    @WalterwhiteAlbuquerqueNM 4 года назад

    Thanks simple and elegant example!!! One suggestion speak a bit louder...!

  • @Heavendev-gz7ev
    @Heavendev-gz7ev 5 лет назад +1

    Hello @Mewan Indula
    If my application is render at first time then data will be loaded successfully............,
    but If I'm refresh my page then why Get() method is goes to in looping condition ??

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      Dear friend, Can you send me the images of your steps what you know please. (mewanindula@gmail.com)

  • @rudiawan4548
    @rudiawan4548 2 года назад

    I've tried to download and try in visual studio 2019 but it's not real time
    please help me

  • @mewanindula5877
    @mewanindula5877  5 лет назад

    If you have any problem regarding this video, please send email to me. mewanindula@gmail.com

  • @namanmalhotra9418
    @namanmalhotra9418 4 года назад +1

    Hello sir I am already using get Data() function but still not able to see real time functionality,Can you please help me

    • @mewanindula5877
      @mewanindula5877  4 года назад

      Could you please re code step by step as I explained in video, without copy pasting?

  • @vikaskumarthakur6469
    @vikaskumarthakur6469 2 года назад +1

    Is this the MVC application in which you are doing the changes ?

  • @universeredrose90
    @universeredrose90 4 года назад +1

    Hi thank you for amazing work, it worked on my local machine but when I connected to remotely DB not working at all could you please help me

    • @mewanindula5877
      @mewanindula5877  4 года назад

      Did you enable the brokers for your remote db?

  • @shadows5315
    @shadows5315 4 года назад +1

    Data is not automatially loading for me also
    Only when refreshed its changing
    Need help on this?

    • @mewanindula5877
      @mewanindula5877  4 года назад

      Please check the installed signalR version with,
      this line inside the _Layout.cshtml.
      Both versions need to be same.
      Thank You!!!

  • @eyyupbalta
    @eyyupbalta 3 года назад +1

    Hello, I am using the mysql database, how do I change it for this?

    • @mewanindula5877
      @mewanindula5877  3 года назад

      I think SQL Dependency doesn't work for MySQL. But you can use SignalR for MySQL

  • @inikaroy8032
    @inikaroy8032 9 месяцев назад

    not changing value if change the database ..

  • @Video-zi3yu
    @Video-zi3yu 4 года назад +1

    Thanks for the effort on this code. I have a problem however. The first time my customer view loads, all is OK with the list of items on the page. But, when I change the database, the controller bypasses the json get() code and goes right to cusHub.Show(). This results in an inaccurate list that is not updated. If I change the database again, no code is fired. Any ideas. Your help is greatly appreciated.

    • @mewanindula5877
      @mewanindula5877  4 года назад

      Did you rewrite the all codes? or copy paste my project?

    • @Video-zi3yu
      @Video-zi3yu 4 года назад

      @@mewanindula5877 Copied and pasted the code but changed the database and field names to match my database. Using SignalR 2.4.1

    • @Video-zi3yu
      @Video-zi3yu 4 года назад +1

      Also, getting following alert: SQL71502: Procedure: [dbo].[SqlQueryNotificationStoredProcedure-11c29b8b-c375-4ae3-9735-470c0297fb85] has an unresolved reference to object [sys].[services].[name]. Currently, I am working on trying to resolve this. Thanks in advance.

    • @mewanindula5877
      @mewanindula5877  4 года назад

      @@Video-zi3yu , Did you enable brockers?
      Could you please re try the all steps without copy pasting all project?

    • @Video-zi3yu
      @Video-zi3yu 4 года назад

      @@mewanindula5877 Yep. Enabled broker. Returned a "1". I'll start over and see if I can get it to work. Stay tuned.

  • @namanmalhotra9418
    @namanmalhotra9418 4 года назад +1

    Hello sir,Everything is working fine,but in order to see updates ,I have to hit refresh button,Can you please help me

    • @mewanindula5877
      @mewanindula5877  4 года назад +1

      Please call getData() function

    • @namanmalhotra9418
      @namanmalhotra9418 4 года назад

      @@mewanindula5877 Already using get data() function,but records are not updating real time,Please help!!!

  • @AvinashReddy21
    @AvinashReddy21 4 года назад +1

    Mewan. It is not working for me. I don't see any errors in console. dependency_OnChange doesn't get fired at all. I have followed all the steps

    • @mewanindula5877
      @mewanindula5877  4 года назад

      what is your signalR version?

    • @giridharan805
      @giridharan805 4 года назад +1

      @@mewanindula5877 ME ALSO SAME PROBLEM THE SIGNALR VERSION IS /Scripts/jquery.signalR-2.3.0.min.js

    • @mewanindula5877
      @mewanindula5877  4 года назад

      @@giridharan805, Is same version that you are calling from cshtml

  • @KidsKingdom286
    @KidsKingdom286 5 лет назад +1

    Hello, nice work, Thank you,
    i get this error message while i am trying to run the application:
    0x800a139e - JavaScript runtime error: SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.
    could you please help?

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      Can you tell me, what is your Installed SignalR version please?

  • @loctran3430
    @loctran3430 4 года назад +1

    Hi thank you for amazing work, it worked. But When I use Procedure realtime not working?

    • @mewanindula5877
      @mewanindula5877  4 года назад

      SQL Dependency doesn't support for Stored procedures. Could you please read sql dependency limitations???

    • @loctran3430
      @loctran3430 4 года назад

      @@mewanindula5877 Thank you so much

  • @mgpyaephyoswe5464
    @mgpyaephyoswe5464 5 лет назад +1

    Hello friend .I want to set notification sound whenever data has been changed.Is there anyway fri ? 😊

    • @mewanindula5877
      @mewanindula5877  5 лет назад +1

      Yes. You can do it friend

    • @mgpyaephyoswe5464
      @mgpyaephyoswe5464 5 лет назад +1

      @@mewanindula5877 Notification with sound work in desktop but I also want to work in andriod webview is that possible fir ?

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      @@mgpyaephyoswe5464, I think you can do it by playing some audio from mobile. But I am 100% not sure friend

  • @rayleung5848
    @rayleung5848 4 года назад

    Good job, is it possibe to set SQL depenancy in table level? If not, I think we can create a StatusChange database, once table changes, trigger a insert record into that database.

    • @mewanindula5877
      @mewanindula5877  4 года назад

      Please can you explain about "SQL depenancy in table level" ?

    • @rayleung5848
      @rayleung5848 4 года назад

      @@mewanindula5877
      Since there is a sentence ”Alter Database customer set enable broker ....”, it seems that if there are many tables perform update action, then it may trigger refresh many times

    • @mewanindula5877
      @mewanindula5877  4 года назад

      @@rayleung5848, I think no. It trigger only table that we mention in sql statement

    • @rayleung5848
      @rayleung5848 4 года назад +1

      @@mewanindula5877 Thanks, I am trying to create and run, but I found (video at 8:23) is missing. Where can I fund this folder?

    • @mewanindula5877
      @mewanindula5877  4 года назад

      @@rayleung5848 it automatically read our hubs that we extended from hub

  • @namanmalhotra9418
    @namanmalhotra9418 4 года назад +1

    can we do this with web api??Please help

  • @asmaaelneanie
    @asmaaelneanie 4 года назад +1

    i have aproblem with this line ( ) i cannot find this>>>thanks :)

    • @mewanindula5877
      @mewanindula5877  4 года назад

      Please rename, jquery.signalR-2.3.0 into your new updated signalR version

    • @asmaaelneanie
      @asmaaelneanie 4 года назад

      @@mewanindula5877 what about that (Unable to get property 'client' of undefined or null reference
      )

  • @juanrubenhernandez6888
    @juanrubenhernandez6888 5 лет назад +1

    My project not change :(

  • @dickparkin9327
    @dickparkin9327 5 лет назад +2

    got a solution for asp core ?

  • @vahittinzaim9542
    @vahittinzaim9542 5 лет назад +1

    11:00
    Specified cast is not valid . How can i fix this

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      After SqlDataReader reader = command.ExecuteReader(); this line,
      if(reader.FieldCount > 0)
      {
      var displayData = db.view_name.ToList();
      }
      Then return your displayData. Plese ignore, Cast and other things

  • @MasterRiddles62
    @MasterRiddles62 5 лет назад +1

    data is not automatically load
    i need to refresh the page

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      It is impossible. There are any errors in console??/

    • @inikaroy8032
      @inikaroy8032 9 месяцев назад

      @@mewanindula5877 yes need to refresh the page again. no console error

  • @vankhanhnguyen2514
    @vankhanhnguyen2514 3 года назад +1

    DO it work in core 2.1 ??? Please

    • @mewanindula5877
      @mewanindula5877  3 года назад

      SignalR works with ASP.NET Core Web API. But I didn't try it with Core MVC Project

    • @vankhanhnguyen2514
      @vankhanhnguyen2514 3 года назад

      @@mewanindula5877 Thanks so much

  • @antoinepelletier256
    @antoinepelletier256 4 года назад

    I don't have Startup.cs, I just added Owin but...

    • @mewanindula5877
      @mewanindula5877  4 года назад

      Are you using library class or something else???

    • @antoinepelletier256
      @antoinepelletier256 4 года назад

      @@mewanindula5877 Never mind, I was not referencing the good SignalR, i took EntitySignal, but EntitySignal does not work without SignalR

    • @antoinepelletier256
      @antoinepelletier256 4 года назад

      ​@@mewanindula5877 My $.connection.cusHub return null

  • @tohabin5064
    @tohabin5064 3 года назад

    in written form:
    techbrij.com/database-change-notifications-asp-net-signalr-sqldependency

  • @_Szakal
    @_Szakal 5 лет назад +1

    does it work also with views?

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      Doesn't work with views in SQL dependency. But you can work with views using another method

    • @_Szakal
      @_Szakal 5 лет назад +1

      @@mewanindula5877 what can i do your tut looks great and i wanted to do the same but you said not work with views So only with tables..

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      @@_Szakal , After SqlDataReader reader = command.ExecuteReader(); this line,
      if(reader.FieldCount > 0)
      {
      var displayData = db.view_name.ToList();
      }
      Then return your displayData. Plese ignore, Cast and other things

    • @_Szakal
      @_Szakal 5 лет назад +1

      @@mewanindula5877 So this solution work for views?

    • @mewanindula5877
      @mewanindula5877  5 лет назад +1

      @@_Szakal , Yes

  • @emresert8044
    @emresert8044 5 лет назад +1

    I did it and the code work succesfully. But I have a question , if we have a column in sql such as datetime,smalldatetime etc , what must we do in part of columnname = (??)x["example-date-column-name"] ? Do you have an answer for solution ? (11:02)

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      I think you have to convert to exact data type. e.g Convert.ToDateTime(). But I am not sure of this solution friend. If you found any solution, please comment in here. Because it will help others. Thank you!!!

    • @emresert8044
      @emresert8044 5 лет назад +2

      @@mewanindula5877
      1-) According to my smalldatetime sql column, sql command should be like :
      SqlCommand command = new SqlCommand(@"SELECT [textId],[textOwner],[textContent], convert(varchar(25), [textDate], 120) as textDate from [dbo].[TextMessage]", connection)
      2-) and we need to convert result to string
      var listMsg = reader.Cast()
      .Select(x => new
      {
      textId = (int)x["textId"],
      textOwner = (string)x["textOwner"],
      textContent = (string)x["textContent"],
      textDate = x["textDate"].ToString() /* here*/
      }).ToList();

    • @mewanindula5877
      @mewanindula5877  5 лет назад

      Thank you friend!!!