publish error in asp.net - 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.

Related

Can't connect to my SQL Server Express from an ASP.NET web app

I'm working on a tool that uses an SQL Server as a database.
First I was using Visual Studio's localdb, then I was using an Azure SQL Server, both of which worked just fine.
I now tried to host my own SQL Server Express, but I can't seem to connect to it. It's hosted in an Azure VM, I have restarted it, enabled TCP and I have opened Port 1433 in Azure.
I have tried both connecting remotely, running the web-app on my local computer and connecting to tcp:{IP}\InstanceName, as well as running the app on an IIS Server on my VM using .\InstanceName in the connection string (although I still get told to check if the server is set up correctly to handle TCP ? )
Connecting locally on the VM, using Microsoft SQL Server Management Studio works though, so I suspect the connection string in my web.config must be wrong ...
It looks like this:
<connectionStrings>
<add name="defaultConnection"
connectionString="Server=tcp:12.345.678.910\InstanceName,1433;Initial Catalog=master;Persist Security Info=False;User ID=sa;Password={mypassword};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
providerName="System.Data.SqlClient" />
</connectionStrings>
The error message I get is:
Server Error in '/application-name' Application. The remote computer refused the network connection.
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.ComponentModel.Win32Exception: The remote computer refused the network connection
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.
Stack Trace: [Win32Exception (0x80004005): The remote computer refused
the network connection]
[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 - The remote computer refused the network connection.)]
(and more but it doesn't seem important - will post if necessary or helpful)
Any idea what I'm doing wrong?
Found the solution on my own:
It's not enough to enable TCP in the Server Configuration Manager, you also have to SQL Server Network Configuration > Protocols for X > TCP > Properties > IP Adresses and set TCP Port to 1433 under IPAll.
SQL Server Express doesn't allow remote connections - by default.
You need to explicitly enable remote connections - easiest way is to use SQL Server Management Studio, connect to it, and then in "Object Explorer" right-click on the server icon, and pick "Properties".
In the dialog that shows up, make sure to tick the "Allow remote connections to this server" checkbox:

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.

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

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.

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?

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.

Resources