ConnectionStringSettingsCollection Class
This page is specific to:.NET Framework Version:2.03.03.54.0
ConnectionStringSettingsCollection Class
Contains a collection of ConnectionStringSettings objects.

Namespace: System.Configuration
Assembly: System.Configuration (in system.configuration.dll)

Syntax

'Usage

Dim instance As ConnectionStringSettingsCollection


'Declaration

Public NotInheritable Class ConnectionStringSettingsCollection
    Inherits ConfigurationElementCollection
public final class ConnectionStringSettingsCollection extends ConfigurationElementCollection
Not applicable.
Remarks

A ConnectionStringSettingsCollection object contains a collection of ConnectionStringSettings objects. Each ConnectionStringSettings object represents a single entry in the <connectionStrings> configuration-file section.

TopicLocation
How to: Access SQL Server Using Predetermined CredentialsBuilding ASP .NET Web Applications
How to: Access SQL Server Using Predetermined CredentialsBuilding ASP .NET Web Applications
How to: Access SQL Server Using Predetermined CredentialsBuilding ASP .NET Web Applications in Visual Studio
How to: Access SQL Server Using Predetermined CredentialsBuilding ASP .NET Web Applications in Visual Studio
How to: Read Connection Strings from the Web.config FileConfiguring ASP .NET Web Applications
How to: Read Connection Strings from the Web.config FileConfiguring ASP .NET Web Applications
How to: Read Connection Strings from the Web.config FileBuilding ASP .NET Web Applications in Visual Studio
How to: Read Connection Strings from the Web.config FileBuilding ASP .NET Web Applications in Visual Studio
Example

The following example shows how to access the ConnectionStringSettingsCollection.

Shared Sub ShowConnectionStrings() 

    ' Get the application configuration file.
    Dim config _
    As System.Configuration.Configuration = _
    ConfigurationManager.OpenExeConfiguration( _
    ConfigurationUserLevel.None)

    ' Get the conectionStrings section.
    Dim csSection _
    As ConnectionStringsSection = _
    config.ConnectionStrings
    
    Dim i As Integer
    For i = 0 To ConfigurationManager.ConnectionStrings.Count
        Dim cs As ConnectionStringSettings = _
        csSection.ConnectionStrings(i)
        
        Console.WriteLine( _
        "  Connection String: ""{0}""", cs.ConnectionString)
        Console.WriteLine("#{0}", i)
        Console.WriteLine("  Name: {0}", cs.Name)
        
        Console.WriteLine( _
        "  Provider Name: {0}", cs.ProviderName)

    Next i

End Sub 'ShowConnectionStrings


The following example is an excerpt from the configuration file used by the previous example.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="ConnStr1" connectionString="LocalSqlServer: data source=127.0.0.1;Integrated Security=SSPI;Initial Catalog=aspnetdb"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>
Inheritance Hierarchy

System.Object
   System.Configuration.ConfigurationElement
     System.Configuration.ConfigurationElementCollection
      System.Configuration.ConnectionStringSettingsCollection
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0, 2.0
See Also

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View