ConnectionStringSettingsCollection.Item[] Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee wordt een ConnectionStringSettings object in de verzameling opgehaald of ingesteld.
Overloads
| Name | Description |
|---|---|
| Item[Int32] |
Hiermee haalt u de verbindingsreeks op de opgegeven index in de verzameling op of stelt u deze in. |
| Item[String] |
Hiermee wordt het ConnectionStringSettings object opgehaald of ingesteld met de opgegeven naam in de verzameling. |
Item[Int32]
Hiermee haalt u de verbindingsreeks op de opgegeven index in de verzameling op of stelt u deze in.
public:
property System::Configuration::ConnectionStringSettings ^ default[int] { System::Configuration::ConnectionStringSettings ^ get(int index); void set(int index, System::Configuration::ConnectionStringSettings ^ value); };
public System.Configuration.ConnectionStringSettings this[int index] { get; set; }
member this.Item(int) : System.Configuration.ConnectionStringSettings with get, set
Default Public Property Item(index As Integer) As ConnectionStringSettings
Parameters
- index
- Int32
De index van een ConnectionStringSettings object in de verzameling.
Waarde van eigenschap
Het ConnectionStringSettings object op de opgegeven index.
Voorbeelden
In het volgende voorbeeld ziet u hoe u toegang krijgt tot een ConnectionStringSettings object in een bepaalde index in een ConnectionStringSettingsCollection verzameling.
static void GetItems()
{
try
{
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// Clear the connection strings collection.
ConnectionStringsSection csSection =
config.ConnectionStrings;
ConnectionStringSettingsCollection csCollection =
csSection.ConnectionStrings;
// Get the connection string setting element
// with the specified index.
ConnectionStringSettings cs =
csCollection[0];
Console.WriteLine(
"cs: {0}", cs.Name);
}
catch (ConfigurationErrorsException err)
{
Console.WriteLine(err.ToString());
}
}
Shared Sub GetItems()
Try
' Get the application configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
' Clear the connection strings collection.
Dim csSection _
As ConnectionStringsSection = _
config.ConnectionStrings
Dim csCollection _
As ConnectionStringSettingsCollection = _
csSection.ConnectionStrings
' Get the connection string setting element
' with the specified index.
Dim cs _
As ConnectionStringSettings = _
csCollection(0)
Console.WriteLine("cs: {0}", cs.Name)
Catch err As ConfigurationErrorsException
Console.WriteLine(err.ToString())
End Try
End Sub
Opmerkingen
In C# is deze eigenschap de indexeerfunctie voor de ConnectionStringSettingsCollection klasse.
Zie ook
Van toepassing op
Item[String]
Hiermee wordt het ConnectionStringSettings object opgehaald of ingesteld met de opgegeven naam in de verzameling.
public:
property System::Configuration::ConnectionStringSettings ^ default[System::String ^] { System::Configuration::ConnectionStringSettings ^ get(System::String ^ name); };
public System.Configuration.ConnectionStringSettings this[string name] { get; }
member this.Item(string) : System.Configuration.ConnectionStringSettings
Default Public ReadOnly Property Item(name As String) As ConnectionStringSettings
Parameters
- name
- String
De naam van een ConnectionStringSettings object in de verzameling.
Waarde van eigenschap
Het ConnectionStringSettings object met de opgegeven naam; nullanders.
Voorbeelden
In het volgende voorbeeld ziet u hoe u toegang krijgt tot een benoemd ConnectionStringSettings object in een ConnectionStringSettingsCollection verzameling.
static void GetItems2()
{
try
{
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// Clear the connection strings collection.
ConnectionStringsSection csSection =
config.ConnectionStrings;
ConnectionStringSettingsCollection csCollection =
csSection.ConnectionStrings;
// Get the connection string setting element
// with the specified name.
ConnectionStringSettings cs =
csCollection["ConnStr0"];
Console.WriteLine(
"cs: {0}", cs.Name);
}
catch (ConfigurationErrorsException err)
{
Console.WriteLine(err.ToString());
}
}
Shared Sub GetItems2()
Try
' Get the application configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
' Clear the connection strings collection.
Dim csSection _
As ConnectionStringsSection = _
config.ConnectionStrings
Dim csCollection _
As ConnectionStringSettingsCollection = _
csSection.ConnectionStrings
' Get the connection string setting element
' with the specified name.
Dim cs _
As ConnectionStringSettings = _
csCollection("ConnStr0")
Console.WriteLine("cs: {0}", cs.Name)
Catch err As ConfigurationErrorsException
Console.WriteLine(err.ToString())
End Try
End Sub
Opmerkingen
In C# is deze eigenschap de indexeerfunctie voor de ConnectionStringSettingsCollection klasse.