0

I'm trying to find out this problem the whole day. I get an error on a website I'm trying to publish :

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: 26 - Error Locating Server/Instance Specified)

I have done everything that other threads have said. Like open firewall ports (To make my life easy i just disabled it) Set up TCP/IP in SQL Server Configuration Manager, also done that set it to 1433. Yet there is something weird there just to say maybe that is it but im not sure on each IP it says Enabled: No

Just thought that was weird but yea. And yes restarted SQL server service like 20 times now. My instance name is SQLSERVER2016 I don't know if that was a smart idea.

I think it's the connection string since in SSMS I can connect to the instance without a problem but I'm not sure I'm still very new to SQL. I've set everything to connect with the Administrator account. So here are my connection strings.

<add name="DefaultConnection" 
     connectionString="Data Source=KEVIN-WEBSERVER\SQLSERVER2016;Initial Catalog=BetaUsersDatabase;Trusted_Connection=yes;MultipleActiveResultSets=true;" 
     providerName="System.Data.SqlClient" />
<add name="ForumDatabase" 
     connectionString="Data Source=KEVIN-WEBSERVER\SQLSERVER2016;Initial Catalog=BetaForumDatabase;Trusted_Connection=yes;MultipleActiveResultSets=true;" 
     providerName="System.Data.SqlClient" />

I've also tried some other variations but they all did not work I have not kept them sorry. But yes, I'm using SQL Server 2016 Express.

1 Answer 1

2

You have a named instance, KEVIN-WEBSERVER\SQLSERVER2016, and the named instance by default is listening on some dynamic port, that of course is not 1433.

In order to connect to a named instance you should provide IP,port or you can use SQL Server Browser and pass in your instance name.

Your connection string does the latter, i.e. you pass in only the instance name, so your SQL Server Browser must be started.

Here Overview of the SQL Server Browser service you find more about SQL Server Browser

Sign up to request clarification or add additional context in comments.

11 Comments

So except form KEVIN-WEBSERVER i do this IPaddress,1433\SQLSERVER2016? And that still does not explance why i can log in like that to SSMS and it works but when i use it in a connection string it fails
Okay it worked putting the IP and port there but can you please tell me why i needed to put that there its a fresh install of everything. why is there so much configuration required?
If your 1433 port works, you did something strange when configurating your instance. 1433 is reserved for default instance, now if someone decides to install a default instance it will fail
If you really use 1433, it will be enough to pass in the computer name only, like this: Data Source=KEVIN-WEBSERVER, and you still will be able to connect
Okay so i still need to learn a lot about this thanks very much.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.