DB Connection ERROR after publishing the web application in IIS 6 - asp.net

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.

Related

Cannot connect dockerized ASP.NET Core app to dockerized SQL Server

I have just configured the project to connect to a dockerized SQL Server. add-migration and update-database commands via VS worked so I think the connection string is fine. I'm guessing it has something to do with the built app being in a container. I don't use docker-compose. I plan on running them separately.
The app successfully ran but it shows this error when performing actions with the database and shows this error:
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: TCP Provider, error: 40 - Could not open a connection to
SQL Server)
The documentations couldn't help me out. Other questions similar to this but none of the solutions worked such as the AllowRemoteConnections set enabled (already enabled by default).

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.

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

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.

Error inserting/deleting records ASP.NET web application deployed on Windows server 2012

I developed an ASP.NET web application and it worked fine locally with IIS express.
I created deployment package and installed the application on my Windows 2012 server.
When developing the application, I was using an mdf file with localdb v11.0. On the server, however, I wanted to use sqlserver express. I changed the connection string to
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\nameoffile.mdf;Integrated Security=True;Connect Timeout=30
After making this change I was able to connect to the application from another host on the network. Viewing data and using filters/search (built into stored procedures) works fine.
The error occurs when I try to insert new records or delete records. The message is:
Server Error in '/Nameofapplication' Application.
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: 50 - Local Database Runtime error occurred.
Cannot create an automatic instance. See the Windows Application event
log for error details. )
I've turned off the firewall, allowed remote connections, started sql server browser and agent and various other solutions that I've found from googling without any luck.
Any ideas about how to solve this issue?

I can't display my pages on ASP.NET

I'm developing a web site with asp.net on localhost, I'm beginner. I wrote a login page and it
works well. However when I click a link, the server can't load the page and gives 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Any idea?
This means you either:
provided the wrong login/password for SQL while using SQL authentication
have used Windows authentication for SQL but the user that your web app is running as doesn't have a login
have provided the wrong connection details for the sql instance so it can't be found
don't have remote connections enabled for that SQL server instance
Are you using SQL server? If yes, run a debug and see what is the connection string at run time and whether you can connect to the DB using the connection string.
In case you are not using SQL server, it seems, you have extended the membership provider but not done so for the role provider. The default role provider tries to connect to SQL Server instance.

Resources