0
대부분의 경험은 응용 프로그램과 관련이 있으며 SQL 쿼리 작업에 문제가 있습니다. 웹 페이지는 signalr을 사용하여 다른 프로세스에 의해 제어 될 새로운 정보로 클라이언트를 업데이트하지만 구현하려는 것은 새로 연결된 클라이언트가 이미 가입 된 다른 클라이언트와 같은 위치에 있지 않아서 새로운 클라이언트를 업데이트합니다. 올바른 정보. 이것은 winapp에서 작동하는 동안 클라이언트가SignalR을 사용하여 SQL 쿼리 실행
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());
}
를 연결할 때 나는이 SQL 쿼리를 가지고, 내가 좋아하는 것
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;
}
반환하기 위해서는 실행하면 내 페이지에 signalr을 모두 중단하지 않습니다 결과를 돌려 준다. 나는 내가해야만하는 일을하고있을 것이므로 나는 물을 것이라고 생각했다.
오류를 게시하십시오. IIS 또는 Visual Studio에서 실행하고 있습니까? –
오류는 없으며 내용은 새로 고침을 시도하지만 성공하지만 항상 비어 있지만 정상적인 문자열은 잘 작동하지만 "hello world"는 작동하지만 "hello world"+ html은 비어 있습니다. 나는 서버상의 IIS와 VS2012에있는 IIS에서 이것을 시도했다. – user685590
나는 당신이 그것을 보내기 전에 html을 인코딩 할 필요가 있다고 짐작하고있다. – rpgmaker