Sunday, 13 January 2013

How to get ConnectionStrings list programmatically in asp.net C#

How to get ConnectionStrings list programmatically in asp.net C#


Step 1)  using System.Configuration;


Step 2)  Get Connection Strings Stored in Web.config

  •   Connection String
  • Name Associated with connection String
  • Provider Name

  foreach (ConnectionStringSettings c in ConfigurationManager.ConnectionStrings)
        {
        Label1.Text += "connection String:"+c.ConnectionString+"  Connection String Name:"+c.Name+
            "   Provider Name:"+
            c.ProviderName+"<br/>";
        }