“The server was not found or was not accessible” Error for SQL Server 2008 - sql-server-2008

Error message is 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: 51 - An instance name was not specified while connecting to a Local Database Runtime. Specify an instance name in the format (localdb)\instance_name.)
And my scenario: IIS and SQL Server 2008 are on the same test workstation, whose firewall is not enabled at all. I don't see any SQL Server log so I can't find any other useful information than the error message above.
I installed SQL Server as default instance (MSSQLSERVER)
My connection string is like this (I am using SQL Server account for authentication):
Server=(localdb); Database=MY_DB_NAME; User ID=MY_USER_ID; Password=MY_PASSWORD
I already verified this user has access to the target database (as owner)
I have gone through some articles on how to track down this problem: I set "allow remote connection" even though IIS and SQL Server are on the same machine. I don't need to set-up firewall.

If you have a standard, unnamed instance, you should use . or (local) (but not (localdb) !) as your server name
Try to use this connection string:
Server=(local); Database=MY_DB_NAME; User ID=MY_USER_ID; Password=MY_PASSWORD

Related

Login failed for user 'sa'

I am trying to connect to a sql server in my asp.net application. I have given connection string in my web.config as follows :
I am getting following error while running the 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)"
If i use remote server's ip address as data source in connection string, I get following error
"Login falied for user 'sa'"
I researched and found some ports need to be opened between the server and my machine, which I got done by network team, still the same issue. How to resolve this ?
You can not directly. you need to have TCP/IP enabled and configured the TCP/IP Ports on sql server configuration manager at remote server.
you need to have TCP/IP connectivity .Just launch it, enter the DNS host name or IP address in the Server Name' box and hit Connect. The hosting company needs to have enabling TCP/IP on your SQL Server instance, and them providing you with secure access to the IP address that instance is running on.
Most administrators do not allow direct access to the SQL Server from outside the firewall. In that case, if you can connect to the host over VPN then you should be able to connect directly to the server with Enterprise Manager or SQL Management Studio.
Please go through it Configurations-Remote-Server
Are you porting code from Hypersonic or H2? If so, the username sa won't work.

Can't access SQL Server 2008 via windows service

I have an application which connects to SQL Server 2008 via windows service.Basically,windows service pics up a configuration file to get connection details like instance name , user name & password.Currently this windows service is failing to start with following error message :-
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)
Application server and DB server are different machines.I can connect to SQL Server via SSMS from application server without any issue. Also I created a UDL on app server and it also connected fine to DB server. Any help here is much appreciated.
Check the account under witch windows service is running- most possible that account is not allowed to make connections to other computers.

Can't connect to local SQL Server

I'm trying to call a sproc from EntLib (MVC3, EntLib5, SQL Server 2008). I'm using the default instance of SQL Server and can connect to it just fine from SQL Server Management Studio. I've tried everything I could find online and nothing gets me connected. The service is running as LocalSystem. Here's the connecction string:
Server=local;Database=Test;Trusted_Connection=True
Here's the error message I'm 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)
Server should be "localhost", not "local", and the "TCP/IP" and "Named Pipes" protocols should be enabled in SQL Server Configuration Manager. Also, if you want to use a trusted connection, you might need to enable Windows Authentication on your MVC3 application, otherwise provide a username and password in the connection string as well.
If you are working with your local SQL Server you need to use localhost or "."

SQL Server add host for connection string

My server name now is AVI-PC\SQLEXPRESS and it is working, I want to add an other host to the SQL Server.
I want to add sqllocalhost\SQLEXPRESS.
So I went to etc/host and added the following line:
127.0.0.1 sqllocalhost
but I could not connect.
So I ping to AVI-PC and I got the following address: fe80::bdc4:33a7:b403:d7f6%10.
So I tried to add
fe80::bdc4:33a7:b403:d7f6%10 sqllocalhost
and still not working.
(I have restart the server and the PC).
Edit
This is the config:
this is the exception:
===================================
Cannot connect to sqllocalhost.
===================================
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) (.Net SqlClient Data Provider)
You want to create an SQL Server alias. Right?
Let's say you have
SEXYMF-PC\SQLEXPRESS
And you want to connect to that server with a different name: dev\SQLEXPRESS
To do that you need to go to Start > All Programs > Microsoft SQL Server 2008 > Configuration Tools > SQL Server Configuration Manager
Once it opens you will see:
SQL Native Client 10.0 Configuration
Client Protocols
Aliases
Right-click on Aliases and click on New Alias. There you enter
Alias Name = dev\SQLEXPRESS
Port No =
Protocol = TCP/IP
Server = SEXYMF-PC\SQLEXPRESS
Click ok and thats it. You can now connect to your SEXYMF-PC\SQLEXPRESS using dev\SQLEXPRESS
EDIT:
Can you connect to "SEXYMF-PC\SQLEXPRESS" using SQL Server Management Studio? If yes, there try to connect to your alias name: dev\SQLEXPRESS. Does it work?
Concerning this message:
(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
1. Check if you have your SQL SErver Browser service on
2. Check again SQL Server Configuration Manager under - SQL Native Client 10.0 Configuration > Client Protocols > Named Pipes - and set to Enabled (if it is disabled).

SQL Server Express - Remote Connection continues to fail

I have been unable to configure my SQL Server 2008 Express to allow remote connections. I followed the instructions from this guide: http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/ .
I am still getting the following error:
Cannot connect to 00.00.00.000
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: 3)
I also configured the firewall as defined in http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/ . As a test I even turned off the firewall, but nothing changed, so it is not the issue.
Update under server name, it only says the IP address. Do I need something more?
In the Server name field of Connect to Server, I had myipaddress. I changed it to myipaddress\SQLEXPRESS and it works.
In addition, once this was working without the firewall I applied settings as defined in http://www.sevenforums.com/system-security/58817-remote-access-sql-server-express-2008-windows-7-a.html to make the connection work with the firewall turned on.
Do you have sysadmin rights in sql express? It may be that your user account doesn't have the necessary permissions. There is a script on codeplex that will add you logged on account as a sysadmin.