Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning SQL query using SignalR
    text
    copied!<p>Most of my experience is with applications and I am having trouble working with a SQL query. The web page uses signalr to update clients with new info which will be controlled by a different process but what I am trying to implement is that new connected clients will not be at the same place as others already joined so it will update new clients with the correct info. I have this SQL Query , </p> <pre><code> public string LoadCurrent() { SqlConnection con = new SqlConnection(); SqlConnectionStringBuilder bldr = new SqlConnectionStringBuilder(); bldr.DataSource = @"server\SQLEXPRESS"; bldr.InitialCatalog = "Signalr_Example"; bldr.UserID = "zip"; bldr.Password = "zap"; con.ConnectionString = bldr.ConnectionString; con.Open(); string currentPage = ""; using (SqlCommand command = con.CreateCommand()) { command.CommandText = "SELECT TOP 1 activepage FROM active"; con.Open(); command.ExecuteNonQuery(); SqlDataReader myReader = command.ExecuteReader(); while (myReader.Read()) { int _currentpage = myReader.GetOrdinal("activepage"); currentPage = myReader.GetString(_currentpage); } } return currentPage; } </code></pre> <p>Which I would like to return when a client connects </p> <pre><code> public Task Connect() { string html = LoadCurrent(); _connections.TryAdd(Context.ConnectionId, null); //This runs firstview which populates a content div on new clients. Clients[Context.ConnectionId].firstview(html); return Clients.tally(_connections.Count.ToString()); } </code></pre> <p>while this works in a winapp , it breaks all of signalr on my page when run and does not return the result. I am probably doing something I am not supposed to , so I thought I would ask.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload