-1

I tried making a site for a school project and when I go ahead and input values in the labels in the register page and send it starts loading for some time and then opens up the code in the server side:

SqlConnection conn = ConnectToDb(fileName); in this line -----> conn.Open();

and this error msg appears:

System.Data.SqlClient.SqlException: '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)'

Robert Paulsen
  • 4,935
  • 3
  • 21
  • 27
yair
  • 1

2 Answers2

0

You should check your connection string and that you have enough permissions to connect to that database

carlos chourio
  • 853
  • 7
  • 16
  • And how do I do that? I mean the connection string should be fine , I checked the route goes to the database – yair Jun 08 '19 at 15:06
0

This is likely because (1) you have the wrong connection string (Example: Wrong server name), or (2) you're loading the connection string from a missing/invalid configuration file. For example, if you're running in debug mode and you your application is trying to load *.debug.config file.

There are other reasons, like you are using NT Authentication and the identity your application is running under does not have SQL Server access.

Robert Paulsen
  • 4,935
  • 3
  • 21
  • 27