September 9, 2016 at 3:43 am
How can I fix this following error? What might be the possible reasons that is blocking me to connect with SQL?
This morning when I tested in UDL with port, it is working fine. SERVER NAME\MSSQLSERVER,1433
Connection string I use in my C# program is "Server=SERVERNAME\\MSSQLSERVER;" +"Integrated Security=SSPI;"+"database=UserAccounts"
. I am using SQL 2012 with visual studio 2012.
An error occurred while attempting to add the account. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)
September 11, 2016 at 10:23 pm
Your problem is probably related to you attempting to connect to an instance called "MSSQLSERVER". Yes this instance name does look like the name of the default instance (e.g. when you look in Services) but when you specify an instance name, SQL tries to find someone with that name which really doesn't exist.
In your connection string that worked, you specify the port number (which happens to be the port number of the default instance) along with an instance name (MSSQLSERVER). The instance name is NOT used when connecting because you specified the port number.
The issue is because when a port number is specified, there is no need to ask SQL Browser for the port number the instance is using ... no need for this because you already have it. If you do not have a port number, and you are not connecting to the default instance (i.e,. you did not specify the name of an instance) then you must ask SQL Browser for the port number.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply