這應該工作:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' You need to add a reference to System.Configuration
' Uncomment to get the count:
' Dim count As Int32
' count = Configuration.ConfigurationManager.ConnectionStrings.Count
Dim current As Configuration.ConnectionStringSettings
For Each current In Configuration.ConfigurationManager.ConnectionStrings
ListBox1.Items.Add(current.Name)
Next
End Sub
注意:如果你還沒有在你的app.config一份聲明中,你可能也得LocalSqlServer,因爲這是由Machine.config中定義的默認。
我看到了,你必須添加對System.Configuration ... Thankyou的引用。 – Jeremy 2010-11-08 04:11:42