Solved

Not able to connect to SQL Server from IIS

Posted on 2012-03-27
3
270 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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