static void AddConnectionStringMyDB() { System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); ConnectionStringsSection csSection = config.ConnectionStrings; ConnectionStringSettings connection = new ConnectionStringSettings(); connection.Name = "Rozn_Client.Properties.Settings.userDBConnectionString"; connection.ProviderName = "Microsoft.SqlServerCe.Client.4.0"; connection.ConnectionString = "Data Source=|DataDirectory|\\myDB.sdf;Password=mypassword;Persist Security Info=True"; csSection.ConnectionStrings.Add(connection); config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("connectionStrings"); }
Изменить строку подключения в app.conig / How to change connection string in app.config
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.