After upload my ASP.NET site cannot login to the admin panel - asp.net

i have developed an asp.net web site for university. in visual studio i gave the server hosted sql server database connection string. not the local one. then when i run it on the local host with server hosted sql server database it allows me to log in to the admin panel.
but after i upload the same set of files which use the same server hosted database connection string, when i try to loging using asp.net template login from to my admin panel, it shows follow error. but in the local host the same hosted sql server worked properly.
i used here asp.net configuration to create the admin and only allowed administrator to access administration folder which has all the side administration pages.
please help me to fix this... thank you!!
Error message
Server Error in '/' 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: 26 - Error Locating Server/Instance
Specified)
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: SQL
Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Are you using an IP address for your connection? If the database is on the same server as your application you will need to use the home address "127.0.0.1" plus any port configuration you might have. Otherwise it wont find itself.
Same goes if your using a URL connection, you might need to add the URL to the server host file so it redirects back home.
The fact that you can connect from your local dosnt mean anything. Its clearly telling you the problem, your "SERVER" cant connect. Do you have Remote Desktop access? If you can, remote into the server and try connecting to your DB from there.

Related

ASP.NET giving SQL Server errors. Possibly due to no log's configured on SQL Server Express

When I run my ASP.NET application I get this error in my browser:
The application could not connect to the database, please check the connection string in the web.config file and SQL server availability.
Original 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: 25 - Connection string is not valid)
I checked Event Viewer and found this error:
initerrlog: Could not open error log file ''. Operating system error = 3(The system cannot find the path specified.).
I have SQL Server Express 2019 installed on my laptop so I checked SQL Server Configuration Manager and found the SQL Server process wasn't running so I tried to start it. It failed with this error:
Right now I'm assuming it's all part of the same issue.
I checked the start up parameters expecting to see something like -eC:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Log\ERRORLOG but there was no parameters and when I tried to add the the Add button greyed out.
I'm also unable to connect through SSMS:
TITLE: Connect to Server
Cannot connect to DESKTOP-GK2MRBG.
ADDITIONAL INFORMATION:
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) (Microsoft SQL Server, Error: 2)
For help, click: http://go.microsoft.com/fwlink?>ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=2&LinkId=20476
The system cannot find the file specified
BUTTONS:
OK
How do I resolve this?

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.

SQL Error login with ASP.NET

Hi I am facing a problem with running exercise file of asp.net Quiz engine when try to make login as admin this message show up in the browser
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)
The first place I would look would would be My Computer > Manage and then click on Services. Scroll down to SQL Server, and verify that the service is started (I noticed on my development environments that occasionally my service will not start event though it is set to automatically start. Also, are you running a default or named instance of SQL Server? If your service is started, and you think your connection string is correct, could you include your connection string (obviously omit any username/password credentials) so that I can see what that looks like?

A network-related or instance-specific error Only in ASP.NET

I am getting “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)” Error when connection throw ASP.NET ONLY . if I try to connect windows application I am able to connect and retrieve values.
I am unable to find any solution
Thanks
Sometimes the simplest things can be the trickiest to discover. I would check to ensure nothing as simple as a typo exists in the name of the SQL Server provided to the ASP.NET application. Make sure that value does, in fact, match that supplied to the Windows application.
If the name is verified correct, I would then make sure that the outbound connection from the ASP.NET application isn't inadvertently trying to go through a proxy server.

publish error in asp.net

i have designed web application in asp.net...i have publish a website..
i have create virtual directory and copy the publish file....
and browse the website...
An error has occurred while establishing a connection to the server. When connecting to >SQL Server 2005, this failure may be caused by the fact that under the default settings >SQL Server does not 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: An error has occurred while >establishing a connection to the server. When connecting to SQL Server 2005, this >failure may be caused by the fact that under the default settings SQL Server does not >allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a >connection to SQL Server)
Source Error:
An unhandled exception was generated during the execution of the current web request. >Information regarding the origin and location of the exception can be identified using >the exception stack trace below.
Your website tries to connect to SQL Server, but the connection string is not matched. You have to change the connection string in your website web.config according to your hosted server.
Open web.config and change the connection string settings.
<connectionStrings>
<add name="DBName" providerName="System.Data.SqlClient" connectionString="uid=; pwd=; database=; server=;Max Pool Size=500"/>
</connectionStrings>
You need to change the connection string and provide uid and password if you are using sql server 2005.One more thing while uploading the published website add the dll from the bin folder
This error might be caused because of several reasons.
1 - Make sure your connection string is correct. You can check here for more info.
2 - Make sure you have "Local and Remote Connections" property is checked with "Using both
Tcp/IP and Named Pipes" option on your SQL Server.
3 - Check your firewall to be sure it does not block requests.
4 - Make sure SQL Server and SQL Server Browser services are started at your computer.

Resources