From 1ba918cfd8b9287033c7ae672cb0cbb00a20b5c1 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 2 Sep 2016 14:05:33 +0000 Subject: [PATCH] =?UTF-8?q?Added=20logic=20to=20use=20=E2=80=9C{DB}?= =?UTF-8?q?=E2=80=9D=20as=20the=20connection=20Initial=20Catalog=20setting?= =?UTF-8?q?=20which=20will=20be=20replaced=20with=20the=20specified=20data?= =?UTF-8?q?base=20name=20from=20the=20\DB=20command=20line=20switch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VEPROMS.CSLA.Library/Generated/Database.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs index e716d232..110e45be 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Database.cs @@ -168,7 +168,7 @@ public static string DBServer else _Methods[str]++; } - if (_VEPROMS_Connection != null ) // Use Lazy Load + if (_VEPROMS_Connection != null) // Use Lazy Load { return _VEPROMS_Connection; } @@ -184,6 +184,8 @@ public static string DBServer // If we are using the DBConnection.xml file, // Check to see if "{MENU}" is being used and if a database was specified (ex."VEPROMS.EXE \DB=VEPROMS_xxx") // If both conditions are true, then call the ChooseDatabases() funtion which will return a valid connection string (we hope) + // Else Check to see if "{DB} is being used and if a database was specified (ex."VEPROMS.EXE \DB=VEPROMS_xxx") + // if both conditons are true, then replace "{DB}" in the connection string with the specified database (_selectedDatabase) without bring up the menu of database // otherwise use the connection string as it is in the DBConnection.xml if (xn != null) { @@ -193,6 +195,13 @@ public static string DBServer { constr1 = ChooseDatabase(constr1); } + else if (constr1.Contains("{DB}")) + { + if (SelectedDatabase != null) + constr1 = constr1.Replace("{DB}", _SelectedDatabase); + else + System.Windows.Forms.MessageBox.Show("A Command Line Switch is required to specify the database.\n\nFor example, where VEPROMSdata is the SQL database name:\n\n /DB=VEPROMSdata", "Cannot Find Database"); + } return _VEPROMS_Connection = constr1; } @@ -208,6 +217,13 @@ public static string DBServer { constr = ChooseDatabase(constr); } + else if (constr.Contains("{DB}")) + { + if (SelectedDatabase != null) + constr = constr.Replace("{DB}", _SelectedDatabase); + else + System.Windows.Forms.MessageBox.Show("A Command Line Switch is required to specify the database.\n\nFor example, where VEPROMSdata is the SQL database name:\n\n /DB=VEPROMSdata", "Cannot Find Database"); + } return _VEPROMS_Connection = constr; } set { _VEPROMS_Connection = value; }