Solved

Not able to connect to SQL Server from IIS

Posted on 2012-03-27
3
271 Views
Last Modified: 2013-01-14
I am not able to connect to the SQL Server from IIS once I publish my web site. I can connect from Visual Studio to the same SQL Server. But the published version of the application on IIS is throwing the following error.


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)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: 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)

Source Error:


Line 514:
Line 515:                // Call the overload that takes a connection in place of the connection string
Line 516:                return ExecuteDataset(connection, commandType, commandText, commandParameters);
Line 517:            }
Line 518:        }
0
Comment
Question by:bcisystems
  • 2
3 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37771323
This mostly happens when either the SQL Server is not reachable from Web Server.
Or you might have mis-spelled the instance name in connection string....

Just verify the config file and see the connection string....
0
 

Author Comment

by:bcisystems
ID: 37771434
I have verified the connection string. Its the same as I have in development. It works within Visual Studio. Is there anything that I need to change for production deployment when we publish?
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37771457
install SSMS on Web Server and try to connect to sql server from there.
If the same error persists, this means there is some network issue....
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question