-1

I was developing, and recompiled started my website with ctrl+F5 and got error:

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)

How can this even happen?

I didn't changed anything.

I started empty MVC application and start it with CTRL+F5 and it works. I restart my main app, and still doesn't work. Damn.

Problem is, that I didn't change any connection string, anything in mssql server, didn't restart anything. I just compiled application like usual, and it said something about Antlr3 first, then couldn't connect to server anymore.. Changed the port for sql express and it started to work for a 20 minutes, and stopped working again.. don't understand.

sensei
  • 7,044
  • 10
  • 57
  • 125

5 Answers5

0

this error threw for two type of problem .

1) Check your connection string for correct server Name and database Name ,etc..

Examble : Setting up connection string in ASP.NET to SQL SERVER

2) Check your sqlserver for open , if your sql server is there is any another system , please check your local network and another system network .

Please see this solution

Community
  • 1
  • 1
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
0

Connect your SQL server from Visual studio > View > server Explorer,test and copy the connection string from there.It will work...My guess is you have a wrong connection string with wrong instance..

Sasidharan
  • 3,676
  • 3
  • 19
  • 37
  • How when everything worked until now? I now made another virtual directory on other port and stuff started working again. what is the point? – sensei Sep 23 '13 at 04:16
0

Is your database can be accessed outside the network. I think you need to add SQL server to firefall application to access it outside.

To add the sqlservr.exe to windows firefall

1. Go to Control Panel\System and Security\Windows Firewall\Allowed Programs.
2. Click Allow another Program.
3. Add SQL Server
Viji
  • 2,629
  • 1
  • 18
  • 30
0

Go to Control Panel -> Administrative Tools -> Services -> SQLServer . Check SQLServer to make sure it is started.

Irfan TahirKheli
  • 3,652
  • 1
  • 22
  • 36
0

I forgot to put [InitializeMembership] attribute in my HomeController.cs, and it was looping forever because I was using RolesMembership ;)

sensei
  • 7,044
  • 10
  • 57
  • 125