AspNet MVC template issue - asp.net

I'm having some trouble with the asp.net "register/login system" that comes ready with the AspNet MVC template.
It worked great for me up until recently that I started receiving the following 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)
I tried running old versions of the code that used to work and they failed as well, I don't know what could have caused it.
Thanks ahead!
Eran

Check the SQL Server service account
If you are not using a domain account as a service account (for
example if you are using NETWORK SERVICE)
you may want to switch this first before proceeding
If you are using a named SQL Server instance
make sure you are using that instance name in your connection strings in your ASweb P.NET application
Usually the format needed to specify the database server is
machinename\instancename
Check your connection string as well
Check that you have connectivity to the SQL Server
. Note what you are using to connect: machine name, domain name or IP address? Use this when checking connectivity. For example if you are using myserver
Start > Run > cmd
netstat -ano| findstr 1433
telnet myserver 1433
ping -a myserver
more info at: http://www.sqlmusings.com/2009/03/11/resolving-a-network-related-or-instance-specific-error-occurred-while-establishing-a-connection-to-sql-server/

This problem occur usually when you publish your project. This happens when there is problem in connection string and make sure you SQL server as well as SQL server browser are running.

Related

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?

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

SQL Server was not found or was not accessible

What is the problem below?
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)
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
How can this be solved?
All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server Services, and check if SQL Server service status is “Running”.
Seeing as this result is second in Google when searching for:
Server is not found or not accessible
I'll add to this post. Colleague of mine has search for an entire day on this problem, checking his connection string and double checking his code. He could connect to the server using SQL but his application wouldn't connect.
Turns out he was running his application from a network share. Network shares only have partial trust and will produce this misleading exception as a result.
Move the project to your local drive and try again. Hope this helps someone!
We were getting this intermittently on our .NET website which accesses an SQL Server database on another server. I tried several things, including making sure I was closing all SQLConnections and recycling applications pools more frequently. These helped some but the problem still occurred from time to time. What it turned out to be was a DNS issue.
I resolved it by changing the connection string Data Source value from a domain name to an IP address, e.g from:
Data Source=My-SQL-Server;Initial Catalog=database-name;Integrated Security=true
to
Data Source=10.1.2.237;Initial Catalog=database-name;Integrated Security=true
This means pretty much exactly what it says. For some reason the computer the code was running on could not communicate with the SQL Server. This could be caused by a lot of things: Firewall issues, DNS/Name resolution, SQL Configuration (not configured to accept TCP/IP connection). Just to name a few.
You need to restart the MS SQL service. Please follow these steps:
1- Press window sign + R to open Run Window.
2- Type services.msc and press Enter.
3- Look for SQLSERVER(MSSQLSERVER) in the services list.
4- Right click on that service and choose REFRESH or START.
Hopefully it works.
Just go through following steps:
All Programs
Microsoft SQL Server 2008 R2
Configuration Tool
SQL Server Configuration Manager
A pop up will open click on yes.
Select Sql Server Services (At left side) and Make sure status is running for all services (At right Side)
One thing you can try is to open server explorer in Visual Studio.
Click Connect to database.
The datasource will be Microsoft SQL Server Database file. Click ok
Type in the Database file name or click Browse...
Click Test Connection and make sure it works.
If it does...click on the Advanced.. button.
Copy the Data Source text at the botton of the screen.
Almost everytime I see this error I was trying to use an instance name something like "long_pc_name/MSSQLExpress" (this is what shows up in MSSMS)
And every time it just needs to be "(LocalDB)\MSSQLLocalDB".
If your connection string is pointing to a local db...
connectionString="Data Source=(localdb)\
Server=localhost\SQLEXPRESS;Database=
Another cause of this error is: you might not have Sql Server installed in your system.
Download Sql Server Express here:
https://www.microsoft.com/en-us/download/details.aspx?id=55994
Install it and try again.
You can use this connection string to connect to it:
Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True;
Your local server name is localhost\SQLEXPRESS.
Replace database with your database name.
Refer to this post if you still have trouble connecting:
Why am I getting "Cannot Connect to Server - A network-related or instance-specific error"?
I was trying to run the MVC Movie tutorial but I had the error in question. So I created a new MVC project and copied its connection string and used that to replace the one in the tutorial. Basically, replace this:
Data Source=(LocalDB)\v11.0
With this:
Data Source=(LocalDb)\MSSQLLocalDB
For all connectionString properties.
Go to SSMS and check if the SQL server is accessible there.
Try to replace domain name by IP address. Check if you have sufficient authorization,and other requirements fulfilled.
Try to check LAN connection and VPN connection, if required.

Problem connecting to a SQL server database from a ASP.NET application

I get the following error whilst trying to connect from an ASP.NET web application from a particular server to an instance of SQL Server 2005 on a different server.
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: SQL
Network Interfaces, error: 26 - Error
Locating Server/Instance Specified)
This article lists 5 steps:
http://blogs.msdn.com/b/sql_protocols/archive/2007/05/13/sql-network-interfaces-error-26-error-locating-server-instance-specified.aspx
We have eliminated each of these (there is no firewall).
Running the application on a different web server (in the same network) and it can connect to the database. Similarly, running the database on a different server, and the application can see it. It appears to be a problem between these two servers.
The problem occurred at random. It was working one minute, then not, and hasn't been working since. Nothing was installed or changed (as far as I can work out) on the server.
Any ideas?
Thanks
Have you tried connecting using an IP address rather than a qualified server name in the connection string? Sometimes the remote server can not be resolved but the IP address can be, depending on domain/network dns setup.

Getting a sql connection error when trying to login

I have a login page that works in my local development environment. When I push the site onto the web server, i am getting this error when trying to login from the asp.net login control.
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I cannot figure out why it does not work on the server. Do I need to add anything or change something in the web.config?
This support article may help. It may also be a firewall issue or an authentication issue on the new setup (but the error message makes that less likely).
For resolving error 26 in sql server you need to do the following steps.
At Server System
1. Under surface area configuration manager-Open up remote connections.
2. Add into firewall 1433 and 1434 port no as n exception.
3. Open port 1433 on router for WAN access.
4. Add client machine ip address as an exception to your antivirus or allow LAN settings in antivirus.
5. Now try to check if both client and server are connected to each other.
for this type "ping IP address of remote system" at run and if reply is obtained then do same for server machine.
If reply is obtained from both machines.
Open Sql server and try to connect to remote machine which allow remote connections using its ip address. U will surely get connected to server machine
See this video
Check to make sure TCP/IP is enabled on the SQL Server. For whatever reason, named pipes and TCP/IP is off by default. Also make sure you are trying to connect to the correct instance (maybe you are using ./SQLEXPRESS locally and on the server SQL is installed on the default instance). Lastly, make sure the database you are trying to connect to exists on the server.

Resources