示例#1
0
        private void b_Zapisz_Click(object sender, EventArgs e)
        {
            Properties.Settings settings = new Properties.Settings();
            settings.Haslo     = tb_haslo.Text;
            settings.Host      = tb_host.Text;
            settings.Login     = tb_login.Text;
            settings.NazwaBazy = tb_nazwaBazy.Text;

            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

            builder.DataSource          = tb_host.Text;
            builder.InitialCatalog      = tb_nazwaBazy.Text;
            builder.PersistSecurityInfo = true;
            builder.UserID   = tb_login.Text;
            builder.Password = tb_haslo.Text;

            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            config.ConnectionStrings.ConnectionStrings["Serwis.Properties.Settings.SerwisConnectionString"].ConnectionString = builder.ConnectionString;
            config.Save(ConfigurationSaveMode.Modified, true);
            Properties.Settings.Default["SerwisConnectionString"] = builder.ConnectionString;

            settings.Save();
            this.Close();
        }
示例#2
0
文件: Form1.cs 项目: alfaKrzys/Serwis
        private void LadujUstawienia()
        {
            Properties.Settings        settings = new Properties.Settings();
            SqlConnectionStringBuilder builder  = new SqlConnectionStringBuilder();

            builder.DataSource          = settings.Host;
            builder.InitialCatalog      = settings.NazwaBazy;
            builder.PersistSecurityInfo = true;
            builder.UserID   = settings.Login;
            builder.Password = settings.Haslo;

            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            config.ConnectionStrings.ConnectionStrings["Serwis.Properties.Settings.SerwisConnectionString"].ConnectionString = builder.ConnectionString;
            config.Save(ConfigurationSaveMode.Modified, true);
            Properties.Settings.Default["SerwisConnectionString"] = builder.ConnectionString;
            settings.Save();
        }