SQL Server add host for connection string - sql-server-2008

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).

Related

SQL Server Mgmt Studio 2014 ; Error 40

I just installed MS SQL SERVER MANAGEMENT STUDIO 2014 , but when I open it I have to add a server name to connect it but it is showing me following error when I enter server name.
TITLE: Connect to Server
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) The system cannot find the file specified
I don't know what to do now, help me out please.
Thanks
Error
Here's mine, if it helps. See if you should have more to it, like SQLEXPRESSPC in my case.
You need to provide an instance name.
Instance Name has been provided during the installation process of SQL Server.
Inside the Server name combobox, you should type something like : .\SQLEXPRESS or .\MSSQLEXPRESS depending on your version of SQLServer.
The .\ refer to your local machine.

“The server was not found or was not accessible” Error for 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

Cannot connect to SQL Azure using SQL Server Management Studio

I have create a SQL Azure database on the Azure portal, now I want to connect to it using SQL Server Management Studio. I've set my properties like this:
Server Type:Database Engine:
Server Name:[mycred].database.windows.net
Authentification: SQL Server Authentification
username: myusername
password: mypassword
But when I try to connecting with these properties I get an 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: Named
Pipes Provider, error: 40 - Could not open a connection to SQL Server)
(Microsoft SQL Server, Error: 53)
Whereas I have configure firewall on my SQL Azure database. How to solve this issue?
Your request has not left your machine that's why it is returning network error. There could be several issues and first start with SQL Server Management Studio. You must have SSMS R2 2008. Any non R2 version will not work.
Here is a list of test you would need to perform to troubleshoot the problem and apply solution:
http://social.technet.microsoft.com/wiki/contents/articles/sql-azure-connectivity-troubleshooting-guide.aspx

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 "."