public string GetArchiveConnectionString() { if (System.Web.HttpContext.Current.Session["Connection_String"] != null) { string subDomainName = System.Web.HttpContext.Current.Request.Url.DnsSafeHost; DataSet dsCredentials = new DataSet(); SPData objData = new SPData(); StringBuilder connectionString = new StringBuilder(); dsCredentials = objData.GetArchiveConnectionString(subDomainName); DataTable dtCredentials = dsCredentials.Tables[0]; if (dtCredentials != null && dtCredentials.Rows.Count > 0) { connectionString.Append("data source="); connectionString.Append(dtCredentials.Rows[0]["RptSqlIPAddress"].ToString().Trim()); connectionString.Append(";Initial Catalog="); connectionString.Append(dtCredentials.Rows[0]["RptDatabaseName"].ToString().Trim()); connectionString.Append(";User Id="); connectionString.Append(dtCredentials.Rows[0]["RptSqlLoginId"].ToString().Trim()); connectionString.Append(";Password="******"RptSqlPassword"].ToString().Trim()); System.Web.HttpContext.Current.Session["Connection_String"] = connectionString.ToString(); } } return(System.Web.HttpContext.Current.Session["Connection_String"].ToString()); }