1

I wrote a website hosted in IIS. The website is using Entity framework . The connection string i use is-

<add name="ShiftEntities" connectionString="metadata=res://*/ShModel.csdl|res://*/ShModel.ssdl|res://*/ShModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=shifts;initial catalog=alfaultdata;persist security info=True;user id=alfaultdata_Admin;password=alfaultdata3!;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />

But i am getting error- The underlying provider failed on Open

How can i solve it?

Misha Groiser
  • 133
  • 11
  • does it work directly from visual studio ? is this asp.net ? asp.net web api ? wcf service ? reporting service ? have you seen the inner exception ? please provide more information sir.. – Yuliam Chandra Jul 27 '14 at 10:26
  • It is working directly from VS. It is a Web Service (HTTP Web Get). – Misha Groiser Jul 27 '14 at 10:34
  • Wrap your web method with `try { /* code */ } catch (Exception ex) { File.AppendAllText("c:\\errlog.txt", ex.Message); File.AppendAllText("c:\\errlog.txt", ex.InnerException == null ? null : ex.InnerException.Message); }` and try again then check the log file.. – Yuliam Chandra Jul 27 '14 at 10:39
  • try to set integrated security in the connection string, `data source=shifts;initial catalog=alfaultdata;Integrated security=True;` – Yuliam Chandra Jul 27 '14 at 10:47
  • when i wrap with a try..catch i receive the following- The server encountered an error processing the request. The exception message is 'The underlying provider failed on Open. Inner- 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'. See server logs for more details. – Misha Groiser Jul 27 '14 at 10:57
  • and trying with Integrated Security didn't help – Misha Groiser Jul 27 '14 at 10:58
  • does the iis and the database located on different machine ? if so, try [this](http://stackoverflow.com/questions/11278114/enable-remote-connections-for-sql-server-express-2012) – Yuliam Chandra Jul 27 '14 at 11:02
  • The IIS and the DB are on different machines. OK But i don't have admin permissions to the SQL Server i am quering and can't change these settings. – Misha Groiser Jul 27 '14 at 11:04
  • OK. Solved. The issue was with with the Connection String Data Source. I had an alias for the datasource and i used it in the connection string instead of the real Data Source Name – Misha Groiser Jul 27 '14 at 11:16

0 Answers0