I'm tyring to connect to the sql server on my lcoal machine and have this error.
"An error has occured establishing connection to the server. Failure may be caused by the fact that under the default settings SQL server does nto allow remote connections.(provider:Named Pipes Provider,error 40 - could not open a connection to sql server)"

Can someone help me fix this?


9 Years
Discussion Span
Last Post by G_Waddell

can you post your code

The code is as follows:

Dim strConn As String = "Integrated Security=True;" & _
"Initial Catalog=Cargo;" & _
"Data Source=localhost"


Is it SQL express or the full version?
If so what version is it?

It's the SqlServer express edition downlaoded from the net. Do I need to make changes to the settings in the configuration Manager?



yes, try that

If that doesnt work you may need to mess about with the config (sql express is set up to be secure by default, so only the local machine can connetc to it. some code doesnt like this)


do like this.

connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
connection = New SqlConnection(connetionString)




I now this thread is like intially two years old but I keep seeing people trying to connection to the SQL express instance using ServerName.

SQLExpress always installs its instance as ServerName\SQLEXPRESS

N.B. You can have as may instances of SQL running on the same machine as you wish but only one can be the default ServerName instance the rest will all be ServerName \InstanceName

This is actually handy if you want to put two diffeerent version of SQL on the same machine e.g. Servername\SQL2000 ServerName\SQL2005 or seperate differnet apps on to different instances for security purposes

There rant over I feel better now...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.