asp.net - SignalR sqlDependency -


i need sql dependency change on gridview displaying rows changed or old data. can me?

here script:

    <script>         $(function () {             var notify = $.connection.notificationshub;             notify.client.displaynotification = function (msg) {                 $("#newdata").html(msg);             };             $.connection.hub.start();         });     </script> </head> <body>     <form id="form1" runat="server">         <div>             <asp:gridview id="newdata" runat="server" autogeneratecolumns="false">             </asp:gridview>   public void sendnotifications()         {             string message = string.empty;             string constr = configurationmanager.connectionstrings["testdb"].connectionstring;              using (sqlconnection connection = new sqlconnection(constr))             {                 string query = "select [message] [dbo].[tb]";                 using (sqlcommand command = new sqlcommand(query, connection))                 {                     command.notification = null;                     sqldependency dependency = new sqldependency(command);                     dependency.onchange += new onchangeeventhandler(dependency_onchange);                     connection.open();                     sqldatareader reader = command.executereader();                     if (reader.hasrows)                     {                        while (reader.read())                              {                                message = reader.getstring(0);                     }                 }             }             }             notificationshub nhub = new notificationshub();             nhub.notifyallclients(message);         }         private void dependency_onchange(object sender, sqlnotificationeventargs e)         {             if (e.type == sqlnotificationtype.change)             {                 sendnotifications();             }         } 


Comments