Is there an easier way of doing the lines below?
var doc = new XmlDocument();
doc.Load("../../../MyWebSite/Web.config");
var mysqlconn = doc.DocumentElement.SelectSingleNode(
"//appSettings//add[@key='mysqlconn']").Attributes["value"].Value;
System.Configuration.ConfigurationManager.AppSettings["mysqlconn"]
Should give you the value. You may want to move them into a <connectionStrings />
section, which you can use:
System.Configuration.ConfigurationManager.ConnectionStrings["mysqlconn"]
.ConnectionString