ConnectionStringsSection.ConnectionStrings Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
ConnectionStringSettingsCollection Mendapatkan koleksi ConnectionStringSettings objek.
public:
property System::Configuration::ConnectionStringSettingsCollection ^ ConnectionStrings { System::Configuration::ConnectionStringSettingsCollection ^ get(); };
[System.Configuration.ConfigurationProperty("", Options=System.Configuration.ConfigurationPropertyOptions.IsDefaultCollection)]
public System.Configuration.ConnectionStringSettingsCollection ConnectionStrings { get; }
public System.Configuration.ConnectionStringSettingsCollection ConnectionStrings { get; }
[<System.Configuration.ConfigurationProperty("", Options=System.Configuration.ConfigurationPropertyOptions.IsDefaultCollection)>]
member this.ConnectionStrings : System.Configuration.ConnectionStringSettingsCollection
member this.ConnectionStrings : System.Configuration.ConnectionStringSettingsCollection
Public ReadOnly Property ConnectionStrings As ConnectionStringSettingsCollection
Nilai Properti
Kumpulan ConnectionStringSettingsCollectionConnectionStringSettings objek.
- Atribut
Contoh
Contoh berikut menunjukkan cara menggunakan ConnectionStrings properti ConnectionStringsSection objek .
static void ShowConnectionStrings()
{
// Get the application configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// Get the conectionStrings section.
ConnectionStringsSection csSection =
config.ConnectionStrings;
for (int i = 0; i <
ConfigurationManager.ConnectionStrings.Count; i++)
{
ConnectionStringSettings cs =
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);
}
}
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
For i As Integer = 0 To ConfigurationManager.ConnectionStrings.Count - 1
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
Berlaku untuk
Lihat juga
Berkolaborasi dengan kami di GitHub
Sumber untuk konten ini dapat ditemukan di GitHub, yang juga dapat Anda gunakan untuk membuat dan meninjau masalah dan menarik permintaan. Untuk informasi selengkapnya, lihat panduan kontributor kami.