Error while trying to connect to SQL Server from webservice in IIS 7.5

4

I'm getting some errors when trying to perform a query on SQL Server from a WebService hosted on an IIS 7.5 server.

My connectionString in web.config:

<connectionStrings>
    <remove name="LocalSqlServer" />
    <add name="TESTEPENDENCIA" providerName="System.Data.SqlClient" connectionString="Data Source=tcp:179.191.87.22; User ID=SISTEMA; Password=SYSUSER;Initial Catalog=TESTEPENDENCIA; timeout=100" />  
</connectionStrings>
<dataConfiguration defaultDatabase="TESTEPENDENCIA" />

Error returned by browser:

  

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server is not found or is not accessible. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

If you remove the "tcp" protocol from Data Source, the following error is returned:

  

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server is not found or is not accessible. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) "

Both errors occur when attempting to access databases on different servers.

The interesting thing is that on another IIS server (unfortunately I can not see the version but it runs on a Windows Server 2003), access to the database normally occurs.

I took a look at the easiest configurations of the IIS server, but I do not have much knowledge to infer some configuration from that alone. My initial idea was that maybe the application was looking for some inherited connectionString, but that does not seem to be the case, since removing the tag from web.config local will claim it.

    
asked by anonymous 17.09.2015 / 18:54

1 answer

1

The problem was an IP access block on the SQL server. IIS 7.5 was on the same network as SQL and I was using an external IP to access it, but it should use an internal IP. The other server accessed exactly because it was on another network.

The reported errors are generic and only indicate that the application was unable to access the database.

    
17.09.2015 / 23:04