Tuesday, February 17, 2009

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 u

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.

When you try to connect to the sql server 2005 remotely the above error may occur. One reason for this eroor is your sql server 2005 configuration is not accepting remote connection. By default sql server express edition and sql server 2005 developer edition do not allow remote connections. To configure sql server 2005 to allow remote connections, complete the following steps.

1. Eanble remote connections on the instance of sql server.
2. Turn on the sql server browser service.

3. Do firewall configuration to allow network trafic related to sql server and browser service.

7 comments:

Anonymous said...

every body describes the same instruction as u but i still getting this error 40..... i wanted to connect 5 system with 1 server server having live ip and windows server.....3 of the systems are working fine.... but 2 of them raising the same exception... wts this bullshit

mutia said...

yea,, i agree with u.. ive done all the instructions n restart my laptop so many times but still got same error!

Jasmin Paul said...

Hi Mutia

can u ping frm ur laptop to ur remote server

If yes try to connect with sql server located in remote machine with the CTP in ur laptop and try to open tables with ur laptop CTP

mutia said...

Sorry,, i dunno actually how to do ping the remote server? is it by using command telnet in cmd?
Cause if so, it come out with the problem on port 23: connect failed

Please provide the steps to make me easier to understand,,
thank you very much! *really need ur help

Top Blogger said...

Ys using

start->run->cmd->ping your server

If it comes with error you first ask network people to correct that


Then make sure your remote server is using sql server enterprise edition start in the server by

Click on start->programs->microsoft sql server 2005->Configuration tools->sql server surface area connction->surface area configuration for services and connections.

Follow the below steps

http://aspnetmembershipprovider.blogspot.com/2009/02/eanble-remote-connections-on-instance.html

Please make sure you are doing this changes in remote server not in your laptop which is client.

Mohamed Shaker said...

Hi all,

I was having the same problem here, and I couldn't find a solution until I turned off the firewall state of all profile of windows 2008 server. After that you will be able to ping your windows 2008 server and to connect to your SQL server. This link describes what I'm trying to say here:
http://blog.benhall.me.uk/2009/01/unable-to-access-or-ping-windows-2008.html

Thanks,,

Anonymous said...

hi friend,
i am using SQL Server 2008.
my problem is i am unable to connect to server through sqlconnection.
i am able to retrive the data from db to gridview directly by using sqldataSource control. but my requirement is like this..
i have a form and if i click on a button i have to insert some data into my database.so, i though of adding the code in the button click event.
i started writing like this...

SqlConnection connection = new SqlConnection();
connection.ConnectionString = "Data Source=A-56AEB715133C4\\SQLEXPRESS;Initial Catalog=States;Integrated Security=True";

connection.Open();
SqlTransaction transaction=null;

transaction = connection.BeginTransaction();
SqlCommand command = new SqlCommand("insert into state_info values('x','1234')",connection);
command.ExecuteNonQuery();
transaction.Commit();

connection.Close();

it is showing the following error..

Format of the initialization string does not conform to specification starting at index 0.

i tried changing the connectionstring by using web.config file..but it is showing the same erro...
please help me out for this..