diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs index a92a62b8..ea6fc87a 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs @@ -58,19 +58,35 @@ namespace VEPROMS.CSLA.Library public static string ConnectionName { get { return Database._ConnectionName; } - set { Database._ConnectionName = value; } + set { Database._ConnectionName = value; _VEPROMS_Connection = null; /* Reset Connection */ } } + private static string _VEPROMS_Connection; public static string VEPROMS_Connection { get { + if (_VEPROMS_Connection != null) // Use Lazy Load + return _VEPROMS_Connection; DateTime.Today.ToLongDateString(); + // If DBConnection.XML exists, use the connection string from DBConnection.XML + string cnOverride = System.Windows.Forms.Application.StartupPath + @"\DBConnection.XML"; + if (System.IO.File.Exists(cnOverride)) + { + System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); + xd.Load(cnOverride); + System.Xml.XmlNode xn = xd.SelectSingleNode("DBConnection/@string"); + if (xn != null) + { + return _VEPROMS_Connection = xn.InnerText; + } + } + // Otherwise get the value from the ConfigurationManager ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings[ConnectionName]; if (cs == null) { throw new ApplicationException("Database.cs Could not find connection " + ConnectionName); } - return cs.ConnectionString; + return _VEPROMS_Connection = cs.ConnectionString; } } public static SqlConnection VEPROMS_SqlConnection