ADO.NET Connection string manipulation in C#

This blog shows on how to manipulate an ADO.NET connection string using C#.



public static void AddAndSaveOneConnectionStringSettings(
       System.Configuration.Configuration configuration,
       System.Configuration.ConnectionStringSettings connectionStringSettings)
{
      ConnectionStringsSection connectionStringsSection = configuration.ConnectionStrings;
      connectionStringsSection.ConnectionStrings.Add(connectionStringSettings);
      configuration.Save(ConfigurationSaveMode.Minimal);
      // ConfigurationManager
      ConfigurationManager.RefreshSection("connectionStrings");
}

Ebook Download
View all
Learn
View all