DB에서 일부 정보를 수집하는 데 사용하는 웹 서비스가 있습니다. 주로 몇 줄. 그러나, 대신 내 기능으로 돌아갑니다. 나는 나중에 호출 할 수있는 함수를 얻고 싶었습니다. 그러나 몇 가지 중단 점을 넣은 후에는 DB에서 방금 가져온 서비스 함수에서 호출이 반환되면 변수를 저장 한 변수가 내 프로젝트로 보입니다.웹 서비스에서 공용 변수를 가져올 수 있습니까?
분명히 웹 서비스가 실제로 어떻게 작동하는지 확신 할 수 없습니다. 세션 변수를 설정하는 것과 같은 특별한 방법이 있습니까? 당신은 클래스 변수에 저장하는 경우
감사
[WebMethod]
public String getDemogs()
{
return Demogs;
}
[WebMethod]
public void LoadUserSites(string username, string siteUse)
{
// Declare the SslConnection class variable.
SqlConnection sSitesConn = new SqlConnection(Util.ConStrEpcrProd);
SqlCommand sSitesCmd = new SqlCommand();
sSitesCmd.Connection = sSitesConn;
SqlDataReader objSitesReader;
try
{
sSitesConn.Open();
if (siteUse == "Main")
{
sSitesCmd.CommandText = "SELECT AgencyName, Demog FROM dbo.UserAdminPermissions WHERE UserName = '" + username + "'";
objSitesReader = sSitesCmd.ExecuteReader();
// Reset the string...
Demogs = string.Empty;
Agencies = string.Empty;
while (objSitesReader.Read())
{
Demogs += objSitesReader["Demog"].ToString() + ",";
Agencies += "'" + objSitesReader["AgencyName"].ToString() + "',";
}
objSitesReader.Close();
objSitesReader.Dispose();
}
finally
{
sSitesConn.Close();
sSitesConn.Dispose();
sSitesCmd.Dispose();
}
}
몇 가지 코드를 보여 주며, 여기에 아무 것도 없이는 도움이 될 수 없습니다. 또한, 어떤 종류의 웹 서비스입니까? asmx? wcf? – Oscar