1
votes

i got the error below when im trying to access my site hosted on Azure. Im using Database connectionString copied straight from the Database management panel on Azure but coudlnt connect successfully

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)]

any ideas how to actually solve it? thanks

3
Are you using this on an IaaS based SQL server or hosted SQL Azure DB? If the former, make sure you have opened the proper ports, if the later, did you set up the IP based access rule?BrentDaCodeMonkey

3 Answers

1
votes

You need to add your azure services or external IP address in a rule into to DB server firewall.

Follow these steps:

  1. Goto Db dashboard
  2. On DB properties click on server name

DB server properties

  1. Then in the new panel goto "All settings"

db server settings

  1. Then goto firewall

db server firewall

  1. enable access from azure services
  2. if need it, add the ip address of you web app.

db server firewall rules

0
votes

the SQL is hosted on Azure, no i have not heard about setting up the IP based access rule, ill check this out

0
votes

thanks for answer, but the solution was that i didn't notice the SQL database i was using was MySQL, and i was using

      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />

instead of

    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />

unfortunately errors didnt say anything about providers being not compatible ;>

btw, sorry, didnt notice i made a post with different account