다음을 통해 공유


ConnectionStringsSection 클래스

정의

연결 문자열 구성 파일 섹션에 프로그래밍 방식으로 액세스할 수 있도록 합니다.

public ref class ConnectionStringsSection sealed : System::Configuration::ConfigurationSection
public sealed class ConnectionStringsSection : System.Configuration.ConfigurationSection
type ConnectionStringsSection = class
    inherit ConfigurationSection
Public NotInheritable Class ConnectionStringsSection
Inherits ConfigurationSection
상속

예제

다음 예제에서는 ConnectionStringsSection사용하는 방법을 보여줍니다.

       // Create a connectionn string element and add it to
       // the connection strings section.
       static ConnectionStrings()
       {
           // Get the application configuration file.
           System.Configuration.Configuration config =
                   ConfigurationManager.OpenExeConfiguration(
                   ConfigurationUserLevel.None);

           // Get the current connection strings count.
           int connStrCnt = 
               ConfigurationManager.ConnectionStrings.Count;

           // Create the connection string name. 
           string csName = 
               "ConnStr" + connStrCnt.ToString();

           // Create a connection string element and
           // save it to the configuration file.
          
           // Create a connection string element.
           ConnectionStringSettings csSettings =
                   new ConnectionStringSettings(csName,
                   "LocalSqlServer: data source=127.0.0.1;Integrated Security=SSPI;" +
                   "Initial Catalog=aspnetdb", "System.Data.SqlClient");

           // Get the connection strings section.
           ConnectionStringsSection csSection =
               config.ConnectionStrings;

           // Add the new element.
           csSection.ConnectionStrings.Add(csSettings);
               
           // Save the configuration file.
           config.Save(ConfigurationSaveMode.Modified);
       }
' Create a connectionn string element and add it to
' the connection strings section.
Shared Sub New() 

    ' Get the application configuration file.
    Dim config _
    As System.Configuration.Configuration = _
    ConfigurationManager.OpenExeConfiguration( _
    ConfigurationUserLevel.None)
    
    ' Get the current connection strings count.
    Dim connStrCnt As Integer = _
    ConfigurationManager.ConnectionStrings.Count
    
    ' Create the connection string name. 
    Dim csName As String = "ConnStr" + connStrCnt.ToString()
    
    ' Create a connection string element and
    ' save it to the configuration file.
    ' Create a connection string element.
    Dim csSettings _
    As New ConnectionStringSettings( _
    csName, _
    "LocalSqlServer: data source=127.0.0.1;Integrated Security=SSPI;" + _
    "Initial Catalog=aspnetdb", "System.Data.SqlClient")
    
    ' Get the connection strings section.
    Dim csSection _
    As ConnectionStringsSection = _
    config.ConnectionStrings
    
    ' Add the new element.
    csSection.ConnectionStrings.Add(csSettings)
    
    ' Save the configuration file.
    config.Save(ConfigurationSaveMode.Modified)

End Sub

다음 발췌문은 이전 예제에서 사용한 구성을 보여줍니다.

<?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>  

설명

ConnectionStringsSection 클래스를 사용하면 구성 파일의 connectionStrings 섹션을 프로그래밍 방식으로 수정할 수 있습니다. 연결 문자열은 ConnectionStringSettingsadd 구성 요소의 ConnectionStringSettingsCollection 제공됩니다.

생성자

ConnectionStringsSection()

ConnectionStringsSection 클래스의 새 인스턴스를 초기화합니다.

속성

ConnectionStrings

ConnectionStringSettings 개체의 ConnectionStringSettingsCollection 컬렉션을 가져옵니다.

CurrentConfiguration

현재 ConfigurationElement 인스턴스가 속한 구성 계층 구조를 나타내는 최상위 Configuration 인스턴스에 대한 참조를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
ElementInformation

사용자 지정할 수 없는 정보와 ConfigurationElement 개체의 기능이 포함된 ElementInformation 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
ElementProperty

ConfigurationElement 개체 자체를 나타내는 ConfigurationElementProperty 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
EvaluationContext

ConfigurationElement 개체의 ContextInformation 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
HasContext

CurrentConfiguration 속성이 null여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
Item[ConfigurationProperty]

이 구성 요소의 속성 또는 특성을 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElement)
Item[String]

이 구성 요소의 속성, 특성 또는 자식 요소를 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElement)
LockAllAttributesExcept

잠긴 특성의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockAllElementsExcept

잠긴 요소의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockAttributes

잠긴 특성의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockElements

잠긴 요소의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockItem

요소가 잠겨 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElement)
Properties

속성의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
SectionInformation

사용자 지정할 수 없는 정보와 ConfigurationSection 개체의 기능이 포함된 SectionInformation 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationSection)

메서드

DeserializeElement(XmlReader, Boolean)

구성 파일에서 XML을 읽습니다.

(다음에서 상속됨 ConfigurationElement)
DeserializeSection(XmlReader)

구성 파일에서 XML을 읽습니다.

(다음에서 상속됨 ConfigurationSection)
Equals(Object)

현재 ConfigurationElement 인스턴스를 지정된 개체와 비교합니다.

(다음에서 상속됨 ConfigurationElement)
GetHashCode()

현재 ConfigurationElement 인스턴스를 나타내는 고유 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
GetRuntimeObject()

파생 클래스에서 재정의될 때 사용자 지정 개체를 반환합니다.

(다음에서 상속됨 ConfigurationSection)
GetTransformedAssemblyString(String)

지정된 어셈블리 이름의 변환된 버전을 반환합니다.

(다음에서 상속됨 ConfigurationElement)
GetTransformedTypeString(String)

지정된 형식 이름의 변환된 버전을 반환합니다.

(다음에서 상속됨 ConfigurationElement)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
Init()

ConfigurationElement 개체를 초기 상태로 설정합니다.

(다음에서 상속됨 ConfigurationElement)
InitializeDefault()

ConfigurationElement 개체의 기본 값 집합을 초기화하는 데 사용됩니다.

(다음에서 상속됨 ConfigurationElement)
IsModified()

이 구성 요소가 파생 클래스에서 구현될 때 마지막으로 저장되었거나 로드된 이후 수정되었는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationSection)
IsReadOnly()

ConfigurationElement 개체가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
ListErrors(IList)

ConfigurationElement 개체 및 모든 하위 요소의 잘못된 속성 오류를 전달된 목록에 추가합니다.

(다음에서 상속됨 ConfigurationElement)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
OnDeserializeUnrecognizedAttribute(String, String)

역직렬화하는 동안 알 수 없는 특성이 발생하는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

역직렬화하는 동안 알 수 없는 요소가 발생하는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
OnRequiredPropertyNotFound(String)

필수 속성을 찾을 수 없는 경우 예외를 throw합니다.

(다음에서 상속됨 ConfigurationElement)
PostDeserialize()

역직렬화 후 호출됩니다.

(다음에서 상속됨 ConfigurationElement)
PreSerialize(XmlWriter)

serialization 전에 호출됩니다.

(다음에서 상속됨 ConfigurationElement)
Reset(ConfigurationElement)

잠금 및 속성 컬렉션을 포함하여 ConfigurationElement 개체의 내부 상태를 다시 설정합니다.

(다음에서 상속됨 ConfigurationElement)
ResetModified()

파생 클래스에서 구현될 때 IsModified() 메서드의 값을 false 다시 설정합니다.

(다음에서 상속됨 ConfigurationSection)
SerializeElement(XmlWriter, Boolean)

파생 클래스에서 구현될 때 이 구성 요소의 내용을 구성 파일에 씁니다.

(다음에서 상속됨 ConfigurationElement)
SerializeSection(ConfigurationElement, String, ConfigurationSaveMode)

파일에 쓸 단일 섹션으로 ConfigurationSection 개체의 무중단 보기를 포함하는 XML 문자열을 만듭니다.

(다음에서 상속됨 ConfigurationSection)
SerializeToXmlElement(XmlWriter, String)

파생 클래스에서 구현될 때 이 구성 요소의 외부 태그를 구성 파일에 씁니다.

(다음에서 상속됨 ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

속성을 지정된 값으로 설정합니다.

(다음에서 상속됨 ConfigurationElement)
SetReadOnly()

ConfigurationElement 개체 및 모든 하위 요소에 대한 IsReadOnly() 속성을 설정합니다.

(다음에서 상속됨 ConfigurationElement)
ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName)

구성 개체 계층 구조가 .NET Framework의 지정된 대상 버전에 대해 serialize될 때 지정된 요소를 serialize해야 하는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationSection)
ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement)

구성 개체 계층이 지정된 대상 버전의 .NET Framework에 대해 serialize될 때 지정된 속성을 serialize해야 하는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationSection)
ShouldSerializeSectionInTargetVersion(FrameworkName)

구성 개체 계층 구조가 .NET Framework의 지정된 대상 버전에 대해 serialize될 때 현재 ConfigurationSection 인스턴스를 serialize해야 하는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationSection)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

ConfigurationElement 개체를 수정하여 저장해서는 안 되는 모든 값을 제거합니다.

(다음에서 상속됨 ConfigurationElement)

적용 대상

추가 정보