In my .NET application, I connect to a Microsoft SQL Server 2005 or 2008 database. The user selects an instance that shows the application, and then the application must do something with that instance. I take the instance names from the registry, HKLM \ Software \ Microsoft \ Microsoft SQL Server \ Instance Names \ SQL.
I do not know if the user selects a default instance instance or a named instance (and there is no such information in the instance name registry values). However, to connect to an arbitrary instance, I have to use either
Server=(local)
or
Server=MSSQLSERVER\instance_name
in my ADO.NET connection string. Can I use only one connection string template? I tried using Server = MSSQLSERVER \ MSSQL10.MSSQLSERVER for my default instance of SQL Server 2008, but the connection failed.
source
share