Error when trying to connect to SQL Server from webservice on IIS 7.5

Asked

Viewed 785 times

4

I am getting some errors when trying to perform a query in SQL Server from a Webservice hosted on an IIS 7.5 server.

My connectionString on the 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 was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote Connections. (Ovider: 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 the Data Source, the following error is returned:

"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. (Preview: Named Pipes Provider, error: 40 - Could not open a Connection to SQL Server)"

The two errors occur when trying to access databases on different servers.

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

I took a look at the easiest settings of the IIS server, but I don’t have much knowledge to infer any configuration just from that. My initial idea was that maybe the application was looking for some inherited connectionString, but that doesn’t seem to be the case, since removing the tag from the web.config local the same claims the lack of it.

  • 1

    Using the IIS Express (development environment) works in a good?

  • I’m sorry, I didn’t quite understand your question (as I said, I’m practically a full layman at ISS). Isn’t ISS Express a lighter, more limited version of ISS? Or is there another way I can test my application on the server other than the default?

  • In the machine in which you developed the webservice works normal? The ISS Express is the tool used to test web applications under development (usually visual studio starts it by itself)

  • Oh yes, sorry. Yes, on the machine the webservice works normally.

  • Behold this link

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 I should use an internal IP. The other server accessed exactly because it was on another network.

Apparently, the errors presented are generic and only indicate that the application could not access the database.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.