I'm facing some issues trying to connect to an SQL Server 2005 using Entity Framework.
I've this small WindowsForm application using a System.Data.SqlClient.SqlConnection:
SqlConnection cnn = new SqlConnection("Data Source=servername\\sqlhotel;Database=mydatabase;User Id=myusername;Password=mypassword");
try
{
cnn.Open();
MessageBox.Show ("Connection is Open ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
This is working fine on my server (I'm getting the "Connection is Open" message), but in my ASP.NET Web API application using Entity Framework 6 I'm getting this error using the above connection string:
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)
Why?