Exemplo n.º 1
0
        private string GetConnectString()
        {
            try
            {
                ConfigManager cfgMgr = ConfigManager.Instance;

                DataSource = cfgMgr.getValueByKey(ConfigConst.CONFIG_DATASOURCE);
                DataBase   = cfgMgr.getValueByKey(ConfigConst.CONFIG_DATABASE_MAIN);

                strID = cfgMgr.getValueByKey(ConfigConst.CONFIG_DATABASE_UID);
                strPW = cfgMgr.getValueByKey(ConfigConst.CONFIG_DATABASE_PASSWD);

#if RELEASE_GWS
                strID = DWEncryptDecryptClass.DecryptString(strID);
                strPW = DWEncryptDecryptClass.DecryptString(strPW);
#endif
                string connectString = "Data Source=" + DataSource +
                                       ";Initial Catalog=" + DataBase +
                                       ";Persist Security Info=True;User ID=" + strID +
                                       ";Password="******";Pooling=True";//应启用连接池 Pooling=True
                return(connectString);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(String.Empty);
        }
Exemplo n.º 2
0
        public void SetConnectString()
        {
            try
            {
#if RELEASE_GWS
                string strDataSource = DWEncryptDecryptClass.EncryptString(DataSource.ToString());
                string strDATABASE   = DWEncryptDecryptClass.EncryptString(DataBase.ToString());
                string UID           = DWEncryptDecryptClass.EncryptString(strID.ToString());
                string PWD           = DWEncryptDecryptClass.EncryptString(strPW.ToString());
                WritePrivateProfileString(title, "DataSource", strDataSource, configPath);
                WritePrivateProfileString(title, "DATABASE", strDATABASE, configPath);
                WritePrivateProfileString(title, "UID", strID, configPath);
                WritePrivateProfileString(title, "PWD", strPW, configPath);
#endif
                //WritePrivateProfileString(title, "DataSource", DataSource.ToString(), configPath);
                //WritePrivateProfileString(title, "DATABASE", DATABASE.ToString(), configPath);
                //WritePrivateProfileString(title, "UID", UID.ToString(), configPath);
                //WritePrivateProfileString(title, "PWD", PWD.ToString(), configPath);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }