Exemple #1
0
        /// <summary>
        /// 加载配置信息.
        /// </summary>
        public void LoadConfig()
        {
            Properties.Settings config = Properties.Settings.Default;
            this.txtPath.Text = config.TestPath;



            string providerName = ConfigurationManager.ConnectionStrings["A4005_Settings.Properties.Settings.TestConnString"].ProviderName;

            this.cboDatabase.Text = providerName;



            string [] connKeyValueArray = config.TestConnString.Split(';');

            foreach (string keyValStr in connKeyValueArray)
            {
                string[] keyValue = keyValStr.Split('=');

                if (keyValue.Length == 2)
                {
                    switch (keyValue[0].ToUpper())
                    {
                    case "DATA SOURCE":
                        this.txtDataSource.Text = keyValue[1];
                        break;

                    case "PORT":
                        this.txtPort.Text = keyValue[1];
                        break;

                    case "INITIAL CATALOG":
                        this.txtInitialCatalog.Text = keyValue[1];
                        break;

                    case "USER ID":
                        this.txtUserId.Text = keyValue[1];
                        break;

                    case "PASSWORD":
                        this.txtPassword.Text = keyValue[1];
                        break;
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 测试读取.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnTestRead_Click(object sender, EventArgs e)
        {
            Properties.Settings config = Properties.Settings.Default;


            this.txtResult.Text = String.Empty;

            this.txtResult.AppendText("测试的 TestPath 属性 = ");
            this.txtResult.AppendText(config.TestPath);
            this.txtResult.AppendText("\r\n");

            this.txtResult.AppendText("测试的 TestConnString 属性 = ");
            this.txtResult.AppendText(config.TestConnString);
            this.txtResult.AppendText("\r\n");



            string providerName = GetProviderName("A4005_Settings.Properties.Settings.TestConnString");

            this.txtResult.AppendText("测试的 TestConnString providerName = ");
            this.txtResult.AppendText(providerName);
            this.txtResult.AppendText("\r\n");
        }