Эх сурвалжийг харах

根据环境判断数据库名

lcl 2 жил өмнө
parent
commit
5c7f348efb
1 өөрчлөгдсөн 7 нэмэгдсэн , 2 устгасан
  1. 7 2
      Startup.cs

+ 7 - 2
Startup.cs

@@ -140,11 +140,16 @@ namespace MySystem
         {
             Dictionary<string, Dictionary<string, string>> tables = new Dictionary<string, Dictionary<string, string>>();
             string connstr = Configuration["Setting:KxsSqlConnStr"];
-            System.Data.DataTable tablecollection = Library.CustomerSqlConn.dtable("select DISTINCT TABLE_NAME from information_schema.columns where table_schema = 'KxsSqlConnStr'", connstr);
+            string dbName = "KxsMainServer";
+            if(Library.ConfigurationManager.EnvironmentFlag == 2)
+            {
+                dbName = "KxsProfitServer";
+            }
+            System.Data.DataTable tablecollection = Library.CustomerSqlConn.dtable("select DISTINCT TABLE_NAME from information_schema.columns where table_schema = '" + dbName + "'", connstr);
             foreach (System.Data.DataRow subtable in tablecollection.Rows)
             {
                 Dictionary<string, string> Columns = new Dictionary<string, string>();
-                System.Data.DataTable columncollection = Library.CustomerSqlConn.dtable("select COLUMN_NAME,DATA_TYPE from information_schema.columns where table_schema = 'KxsSqlConnStr' and TABLE_NAME='" + subtable["TABLE_NAME"].ToString() + "'", connstr);
+                System.Data.DataTable columncollection = Library.CustomerSqlConn.dtable("select COLUMN_NAME,DATA_TYPE from information_schema.columns where table_schema = '" + dbName + "' and TABLE_NAME='" + subtable["TABLE_NAME"].ToString() + "'", connstr);
                 foreach (System.Data.DataRow column in columncollection.Rows)
                 {
                     string datatype = column["DATA_TYPE"].ToString();