tags:

views:

495

answers:

3

I'm using SQL Server 2008 and in Visual Studio, in Server Explorer, I can connect to SQL Server running using my computer name, but I can't using 127.0.0.1 or localhost, shouldn't they be the same?

Also when using a connection string in the web.config file for the website I can't connect using localhost, but only with the computer name! Is there some setting I'm missing somewhere in the SQL Config Manager?

A: 

Use localhost\sql_server_instance_name

For example, localhost\sqlexpress

Use . instead of 127.0.0.1

.\sqlexpress

adatapost
The OP has said that it works with the machine name but not with "localhost" or the IP address, but didn't mention any instance name..
Rob
+3  A: 

You probably need to set Sql Server to allow "remote" connections:

  1. Go to Start > All Programs > Microsoft Sql Server 2008 > Configuration Tools > Sql Server Configuration Manager
  2. When the configuration manager has loaded, expand the "SQL Server Network Configuration" node of the treeview to the left
  3. Select the Sql Server instance that you're trying to connect to in the tree
  4. All three of "Shared Memory", "Named Pipes" and "TCP/IP" should show as Enabled in the list to the right. For any that don't, double click each one in turn and change Disabled to Enabled in the window that appears.
  5. Click on "Sql Server Services" in the treeview
  6. Choose "SQL Server (InstanceName)" (where InstanceName will probably be SqlExpress or MsSqlServer), right click and choose Restart

Once the restart has completed, try connecting again - it should work now.

Rob
Hi Rob, thanks but they are already enabled. It throws an error now even when using my computer name! I just reinstalled SQL 2008 on a different machine and says COMPUTER92/SQLSERVER can not login to database "mdbb" (computer 92 is my computer name, its is a valid Login under the server security -> logins, and it says its mapped to "mdbb" but under the users it doesn't show COMPUTER92/SQLSERVER as a user of "mdbb" !!
A: 

You can also try: .\sql_server_instance_name

.\SQLExpress

Investor5555