Solved

Not able to connect to SQL Server from IIS

Posted on 2012-03-27
3
264 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now