Code:
this.comboServer.DropDown += new System.EventHandler(this.comboServer_DropDown);
private void comboServer_DropDown(object sender, EventArgs e)
{
comboServer.Items.Clear();
System.Data.Sql.SqlDataSourceEnumerator instance = null;
System.Data.DataTable dataTable = null;
try {
instance = System.Data.Sql.SqlDataSourceEnumerator.Instance;
dataTable = instance.GetDataSources();
foreach (System.Data.DataRow row in dataTable.Rows) {
comboServer.Items.Add(row["ServerName"]);
}
} catch(Exception) {
} finally {
try { if(dataTable != null) dataTable.Dispose(); } catch(Exception) { }
}
}