| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Linq; |
| | |
| | | } |
| | | public DBHelper() |
| | | { |
| | | //sServer = "47.96.97.237,15127"; |
| | | //sDataBase = "HX_LMESsys"; |
| | | //sUser = "HX_USER"; |
| | | //sPassword = "lc@841022"; |
| | | //斯莫尔 |
| | | sServer = "10.11.18.195"; |
| | | sDataBase = "HX_LMESsys_test"; |
| | | sUser = "HX_USER"; |
| | | sPassword = "lc@841022"; |
| | | sServer = GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "sServer"); //"10.11.18.195"; |
| | | sDataBase = GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "sDataBase"); //"HX_LMESsys_test"; |
| | | sUser = GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "sUser"); //"HX_USER"; |
| | | sPassword = GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "sPassword");// "lc@841022"; |
| | | } |
| | | |
| | | public static String GetConfigKey(String configPath, String key) |
| | | { |
| | | Configuration ConfigurationInstance = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap() |
| | | { |
| | | ExeConfigFilename = configPath |
| | | }, ConfigurationUserLevel.None); |
| | | |
| | | |
| | | if (ConfigurationInstance.AppSettings.Settings[key] != null) |
| | | return ConfigurationInstance.AppSettings.Settings[key].Value; |
| | | else |
| | | |
| | | return string.Empty; |
| | | } |
| | | |
| | | private bool CnOpen()//OPEN数据库连接 |