connectionstring in web.config - asp.net

I have a connection string at web.config. The data source is ".\SQLEXPRESS"
This works fine on local machine, but when I published the website using vs and an error occurred about sql connection.
I think there is some problem with ".". Then I changed it to an IP Address, after that error occurred on both the local and remote machine.
I think the problem lies on the expression of data source. Can anyone help me resolve this?
The error is:
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)

The use of "." is simply a shortcut for "localhost". You must verify that there is a SQLEXPRESS named instance on the machine you are deploying to. If this is not the case, you must specify an appropriate data source. You mentioned using an IP Address which will work, but that will again require an accessible endpoint at that location.
For more help, see the following:
http://www.sqlmusings.com/2009/03/11/resolving-a-network-related-or-instance-specific-error-occurred-while-establishing-a-connection-to-sql-server/

Related

SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified while connecting via asp.net application

While connecting to SQL Server 2012 Express from Asp.Net application, I get the following exception:
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)
Though, I can connect remotely to the SQL Server but once I published the application to the server where the db resides, I got the above exception.
I tried various approaches shared on net but nothing worked for me. Any suggestions?
There should be a problem in your connection string. check the instance name from Sql Server and then paste that instance name in your connection string.
This error is one of the worst, because you normally don't know what exactly the problem is. Here are some possible solutions:
Check that the server name is correct
Check that the instance name is correct
Check that your server is reachable (seems not to be your problem)
Check that the SQL Browser service is running
Check the firewall rules
Sometimes SQL Error 26 just hides another problem with the connection (f.e. SQL Error 0).

Webparts in asp .net

I am trying to understand how webparts work exactly and what do they do.
I added a webpartmanager and a catalogzone to the page. My only problem is that I get a network exception like this:
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)
I am guessing that the configuration for webparts is stored in a database but I can't find a connection string anywhere in the webpartmanager and I am pretty clueless how to set up the database.
Open SQL Server Manager and enable Named Pipes and TCP/IP:
SQL SERVER – FIX : ERROR

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.

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.

Error when connect to remote SQL Server

I try to connect to remote SQL Server 2008 Express database from my ASP.NET web application but error throws:
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)
How to resolve that problem. Thanks!
Here's the first thing to check. By default Express only has the shared memory protocol enabled. You'll need to enable TCP/IP protocol for the service (SQLEXPRESS). You do this through the SQL Server Configuration Manager.
Also since Express is a named instance, you'll need to ensure that the SQL Server Browser service is started.
Make sure your connection string is correct. When you are hitting a named instance (SQLEXPRESS in this case) you need to have the data source as yourServer\sqlexpress.
And not to mention, make sure you can ping the box that houses the instance.
Check those things out and let me know if that still doesn't fix it.
i thing your connection string is not correct. Also check a named instance you try to data source as IPaddress\sqlexpress. Like 000.000.000.000\SqlExpress

Resources