Interface: Automatic Lookup

Mar 13, 2008 at 8:42 PM
I noticed the application servername is a listbox control, but does not automatically search. I ran into another similar issue some time back created an applicaiton for one of my installs.

I thought it may help, so here is my code for how I do that. I originally wrote it in VB but then switched it to run in c#. At least I think it will. :) You will need only add a button for refresh like ... private void YOURBUTTONNAMEHERE_Click(object sender, EventArgs e).... Then add the following code.
{
SQLDMO.Application oSQLServerDMOApp = new SQLDMO.Application();
SQLDMO.NameList oNameList;
oNameList = oSQLServerDMOApp.ListAvailableSQLServers();

for (int intIndex = 0; intIndex <= oNameList.Count - 1; intIndex++)
{

if (oNameList.Item(intIndex as object) != null)
{

YOURLISTBOXCONTROLNAMEHERE.Items.Add(oNameList.Item(intIndex).ToString());

}

else
{

YOURLISTBOXCONTROLNAMEHERE.Items.Add("(Local)");

}

}

CHANGETOYOURLISTBOXCONTROLNAMEHERE.SelectedIndex = 0;
}
Coordinator
Mar 13, 2008 at 9:08 PM
Edited Mar 13, 2008 at 9:09 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.

Thanks Gary