Anand Kannan

Anand Kannan

  • NA
  • 26
  • 1.7k

how to get server name in microfocus and use the web config

Mar 11 2014 11:41 AM
I am trying to get the server name in microfocus asp.net and use the same to invoke the connection string from web config.
 This is what we do in asp.net - is there a analogous syntax in Microfocus - 
 
<appSettings>

<add key="devconn" value="Data Source=XX\YY;Initial Catalog=XXXTEST;Persist Security Info=True;User ID=XXXWEB;Password=12345678"/>
</appsettings>


if (HttpContext.Current.Request != null){
strSvrName = HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString();
}

switch (strSvrName.ToUpper())
{
case "LOCALHOST":
case "XXXDEV.WEB.XXX.COM":
string strDbConn = ConfigurationManager.AppSettings["devconn"];
break;
case "XXXTST.WEB.XXX.COM":
string strDbConn = ConfigurationManager.AppSettings["testconn"];
break;

case "XXXPRE.WEB.XXX.COM":
string strDbConn = ConfigurationManager.AppSettings["prodconn"];
break;
case "XXX.WEB.XXX.COM":
break;

}
 
Thanks
Anand

Answers (1)