Good afternoon,
I have a windows form that I am working with. When I first wrote this code it worked and was able to pull a list of SQL Servers for a ComboBox, and then as I changed servers it would populate another ComboBox with databases. I had not updated the code in a few years, and it is using .net 4.6.1 and the Microsoft.SqlServer.SqlManagementObjects version: 150.18147.0. I went to use the program and launched it now it is not returning any sql servers. I opened up visual studio and went to debug it and it is still not returning servers.
All this code is contained within the form class itself.
private async void ActiveStatuses_LoadAsync(object sender, EventArgs e)
{
//List all the servers, if only want to see local set to true
DataTable dataTable = await System.Threading.Tasks.Task.Run(() => { return SmoApplication.EnumAvailableSqlServers(false); });
cbServers.ValueMember = "Name";
cbServers.DataSource = dataTable;
}
private void cbServers_SelectedIndexChanged(object sender, EventArgs e)
{
cbDatabases.Items.Clear();
if (cbServers.SelectedIndex != -1)
{
string serverName = cbServers.SelectedValue.ToString();
Server server = new Server(serverName);
try
{
foreach (Database database in server.Databases)
{
cbDatabases.Items.Add(database.Name);
}
}
catch (Exception ex)
{
string excepection = ex.Message;
}
}
}
private void cbDatabases_SelectedIndexChanged(object sender, EventArgs e)
{
string databaseName = cbDatabases.SelectedItem.ToString();
}
I cannot see why this would stop working and debugging shows enumeration yielded no results. Also it does output any errors.