Code Snippet posted by: Johnbhatt
| Posted on: 7/20/2012 | Category: C# Codes
| Views: 395 | Status: [Member]
| Points: 40
| Alert Moderator
private void Form1_Load(object sender, EventArgs e)
Description of Above Code:
panel1.Visible = false;
groupBox1.Visible = false;
label9.Visible = true;
label9.TextAlign = ContentAlignment.MiddleCenter;
SqlDataSourceEnumerator SerInstances = SqlDataSourceEnumerator.Instance;
DataTable SerNames = SerInstances.GetDataSources();
for (int index = 0; index <= SerNames.Rows.Count - 1; index++)
We have placed rest design in Panel and Groupbox so we set that invisible on Form Load. Please Make a Conncetion First.. is Label9 and we set is Visible and aligned.
Now main task is to List Sql Servers on Network. For this we used SqlDataSourceEnumerator class.
In Next Line we take a DataTable and stored ServerInstances into that.
Rest is Simple, We added all items into Listbox. Column 0 contains Machine name and Column 1 contains Instance Name. So we combined that at the Time of Adding to ComboBox Control.
Glad to Know, Free to Share.....