yoda
yoda

Reputation: 569

Error while connecting to SQL server 2005

An error occured while establishing a connection to the server. When connecting to the SQL server 2005, the failure may be caused by the fact that under the default settings SQL server does not allow remote connections. (provider: Named pipes provider, error: 40 - Could not open a connection to SQL server)

I am using .NET framework provider for SQL Server and Visual Studio 2008.

Data Source=.\SQLEXPRESS;AttachDbFilename="";Integrated Security=True;User Instance=True

What am I missing here?

Upvotes: 0

Views: 602

Answers (3)

Mark Kram
Mark Kram

Reputation: 5832

An error occured while establishing a connection to the server. When connecting to the SQL server 2005, the failure may be caused by the fact that under the default settings SQL server does not allow remote connections. (provider: Named pipes provider, error: 40 - Could not open a connection to SQL server)

By default SQL Server Express disables remote connections via TCP/IP and Named Pipes, so you will need to enable these protocols in the SQL Server Configuration Manager (Start --> Programs --> Microsoft SQL Server 2008 --> Configuration Tools).

enter image description here

I also agree with Hogan about ConnectionStrings.com great site!

Upvotes: 1

cmsjr
cmsjr

Reputation: 59165

AttachDbFilename should be the path to the database filed (generally a .mdf) that you will be using.

Data Source=.\SQLEXPRESS;AttachDbFilename=c:\some.mdf;Integrated Security=True;User Instance=True

Upvotes: 1

Hogan
Hogan

Reputation: 70513

I know external references are bad, but it really does not get better than this:

http://www.connectionstrings.com/

as they say

 Server=.\SQLExpress;AttachDbFilename=c:\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;

Upvotes: 1

Related Questions