I'm totally confused of how to get the local sql server instance. The only thing I receive is the Server names. Here are the different approaches I have tried:
DataTable availableServers = SmoApplication.EnumAvailableSqlServers([All of the 3 inputs]);
foreach (DataRow serverRow in availableServers.Rows)
{
// foreach row list "Name", "Server", "Instance" etc...
}
and
SqlDataSourceEnumerator sdse = SqlDataSourceEnumerator.Instance;
DataTable table = sdse.GetDataSources();
foreach (DataRow row in table.Rows)
{
// foreach row list "ServerName", "InstanceName", "IsClustered" and "Version"
}
and
ManagedComputer mc = new ManagedComputer();
ServerInstance instance = mc.ServerInstances;
Is there some other way I can get the local sql server instance name?
I know that when connecting to SQL server in management studio the connect dialog displays my local instance as .\sqlexpress or (local)\sqlexpress. Also when deploying a database installation in InstallShield the InstallShield "locate sqlserver"-dialog gets the correct instance for my local host. What are they doing correct?
