Connection issue between Asp.Net 4.5 app and SQL Server 2012 - asp.net

I have a web forms application that is connecting to a SQL Server 2012 database. When I try to open the connection within the app I get this error:
System.Data.SqlClient.SqlException (0x80131904): 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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.) ---> ...
I've checked and SQL server is configured to allow remote connections, TCP/IP is enabled, the server is up and I can connect to it via SSMS and Linqpad.
This is occurring when I run the application locally, hitting a local database. I know the connection string works, as I can use the login in SSMS to login and I have a linqpad query that is working with no problem using the same connection string. Also the error occurs when I try to open the connection (i.e. the connection is created successfully).
I'm guessing there is some access/security issues with my configuration of IIS, but I not finding it.

After a couple of frustrating days, I discovered the solution. The problem was that SQL server wasn't setup to use TCP/IP. This is configured in the Sql Server Configuration Manager, under the SQL Serer Network Configuration node, then Protocols for MSSQLSERVER. Make sure TCP/IP is enabled.

Related

SQL Server not connecting via IIS

I am getting the following error when I deploy my application to IIS:
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)]
What is interesting about this is that it is happening at the folder level. I have the same application, running on the same IIS server and it connects to the SQL server without issue - and the complied code is the same. The only difference is the folder that has the content. I am leaning towards a permission issue - but I did not change any of those.

DB Connection ERROR after publishing the web application in IIS 6

After publishing web application in IIS 6 I am getting follwoing 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)
It runs fine in development server with same DB connection
Please help me
there can be multiple issues with this. But basic problem is that web server is not able to locate DB server.
Try below steps to figure out the exact issue
is the DB server pingable from your web server?
are you providing correct user while connecting to SQL server.
are you able to connect to the DB server from web server using the username you provided in your config file?
try all above and let me know your result.

Asp.Net With SQL Server And Asp.net Linq Application

I have an application that uses linq-to-sql with Sql Server Express 2008. When I use the DBML file in a separate DAL project and refer to it to my web project, on execute Sql Server shows this 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
But when I use the DBML in my web project, debugging is without any problem. But on IIS in Windows 7 64bit i get:
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)
Do these two errors have the same cause? Is the connection string not correct?
I'd suspect that in the first case you have the connection string in the DAL project and not in your web project (where it belongs). Make sure you copy it to the web.config of your web project.
In the second case I think that that the machine hosting IIS tries to connect to the database on your own machine. If so, check the exception: make sure your SQL Express instance is configured to allow remote connections, that the IP protocol is enabled (named pipes if for local traffic), and that your machine is accessible to the IIS machine.
I think, Your connections string is wrong.
dont worry.
check your dbml's designer.cs file. in which you will find '<YourDBMLFile>DataContext()' Constructor.
and Change your Connection string. make sure your connectionstring is correct.

Unable to Connect to SQL Server Database using ASP.NET Webservice

I have a website and a webservice. Both uses same Data Access Layer. Both uses same connection string to connect to SQL Server 2008. But my website is able to connect to the database but webservice throws following exception:
Server was unable to process request. ---> System.Exception: System.Exception: 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.
Other then verifying the connection string/network level stuff, is there any "out of the box" error that might cause this issue?
Database: SQL Server 2008
OS: Windows Server 2008 R2
.NET Framework: 2.0
I'm guessing the web server and DB server are on two different boxed. First ensure that external connections are permitted by the SQL server, then ensure that the port is open between the two server (you can do this using telnet).

Cannot connect to SystemDSN ODBC datasource IIS 7

I have configured odbc datasource as System DSN.
It works fine by itself and from Visual studio.
When I try to start applicattion under the IIS 7 on connection I get an error:
ERROR [08001] [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [5].
ERROR [HYT00] [Microsoft][SQL Server Native Client 10.0]Login timeout
expired
ERROR [08001] [Microsoft][SQL Server Native Client 10.0]A
network-related or instance-specific error has occurred while
establishing a connection to SQL Server. Server is not found or not
accessible. Check if instance name is correct and if SQL Server is
configured to allow remote connections. For more information see SQL
Server Books Online.
IIS Application runs as different user - this user has no access premonitions to somewhere that ODBC uses.
I changed ApplicationPool identity to ran as administrator - this solved my problem. This was the fast solution. At least this is dirrection to dig. :)

Resources