-1

I have multiple Web applications running on the same server. All are MVC.

I created a new Asp.Net MVC app and placed it on the server. Changed the Connection String values and it's throws the following error. I am stumped with this. SQL Server is set to allow remote connections. Connection String references the correct named instance.

This is my connection string in web.config

<connectionStrings>
    <add name="RAD_SystemEntities" connectionString="metadata=res://*/Models.RADSystem.csdl|res://*/Models.RADSystem.ssdl|res://*/Models.RADSystem.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=ServerName\NAMED_INSTANCE;Initial Catalog=RAD_System;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=sa&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

Following is the 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) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Exception: 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)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[Exception: 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)]
TotalDesk.Controllers.HomeController.Index(User model) +7147
lambda_method(Closure , ControllerBase , Object[] ) +104
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +181
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +27
System.Web.Mvc.Async.<>c__DisplayClass42.b__41() +28 System.Web.Mvc.Async.<>c__DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _) +10 System.Web.Mvc.Async.WrappedAsyncResult1.End() +50 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
System.Web.Mvc.Async.<>c__DisplayClass39.b__33() +58 System.Web.Mvc.Async.<>c__DisplayClass4f.b__49() +225 System.Web.Mvc.Async.<>c__DisplayClass37.b__36(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResult1.End() +50 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24 System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +99 System.Web.Mvc.Async.WrappedAsyncResult
1.End() +50 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.<>c__DisplayClass1d.b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +23 System.Web.Mvc.Async.WrappedAsyncResult1.End() +55
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39 System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23 System.Web.Mvc.Async.WrappedAsyncResult
1.End() +55
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +23 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9667432 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

RBT
  • 24,161
  • 21
  • 159
  • 240
Orion
  • 452
  • 6
  • 23
  • Thank you kindly for assisting with formatting. – Orion Jan 22 '17 at 00:00
  • Is that your actual connection string? It looks doubled-up. – Jasen Jan 22 '17 at 00:11
  • That is how it was generated from Visual Studio. I just copied the whole project to server and changed the username and passwords only. On my local copy it works fine. – Orion Jan 22 '17 at 00:17

2 Answers2

0

your problem is with the database -

To begin - there are 4 issues that could be causing the common LocalDb SqlExpress Sql Server connectivity errors SQL Network Interfaces, error: 50 - Local Database Runtime error occurred, before you begin you need to rename the v11 or v12 to (localdb)\mssqllocaldb

I found that the simplest is to do the below - I have attached the pics and steps for help.

First verify which instance you have installed, you can do this by checking the registry and by running cmd

  1. cmd> Sqllocaldb.exe i
  2. cmd> Sqllocaldb.exe s "whicheverVersionYouWantFromListBefore" if this step fails, you can delete with option d cmd> Sqllocaldb.exe d "someDb"
  3. cmd> Sqllocaldb.exe c "createSomeNewDbIfyouWantDb"
  4. cmd> Sqllocaldb.exe start "createSomeNewDbIfyouWantDb"

SqlLOCALDb_edited.png

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Transformer
  • 6,963
  • 2
  • 26
  • 52
  • Thank you for the how to. Sorry for the late reply.I have been overwhelmed with getting things fixed on my side. I found that the issue was the Entity Framework versions. I had an incompatible version in my project to what was in GAC. – Orion Jan 27 '17 at 23:24
0

My issue was that I had the inccorect Entity Framework in my project to what was in the GAC. have changed my Entity Framework version to be the same as version in GAC and the issue has been resolved.

If you are doing the same. Please make sure to update the references in config files to the correct version

Orion
  • 452
  • 6
  • 23