Monday, February 20, 2012

Problem connection to Express Edition with C#

I'm using .NET 2.0 and SQL Server 2005 Express Edition on WinXP SP2. I'm
using System.Data.SqlClient to connect to the server which is on the same
machine. The SQL Server service is set to log on as "Built-in account: Local
System" and the connection string I'm passing to the constructor is "Data
Source=(local);Initial Catalog=TestDB;" everything else is set to defaults.
I get the following error: "System.Data.SqlClient.SqlException: 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. (provider:
Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
"
Any help would be greatly appreciated.I was fiddling around with different connection strings and this one finally
allowed me to connect: "Data Source=.\\SQLEXPRESS;Initial
Catalog=TestDB;Integrated Security=SSPI;"
"Frustrated" wrote:

> I'm using .NET 2.0 and SQL Server 2005 Express Edition on WinXP SP2. I'm
> using System.Data.SqlClient to connect to the server which is on the same
> machine. The SQL Server service is set to log on as "Built-in account: Loc
al
> System" and the connection string I'm passing to the constructor is "Data
> Source=(local);Initial Catalog=TestDB;" everything else is set to defaults
.
> I get the following error: "System.Data.SqlClient.SqlException: An error h
as
> occurred while establishing a connection to the server. When connecting t
o
> SQL Server 2005, this 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 Serve
r)"
> Any help would be greatly appreciated.|||You 'normally' always provide at least three pieces of information for a
connection. The Server, the database, and the security context.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"Frustrated" <Frustrated@.discussions.microsoft.com> wrote in message
news:0C3946E2-F417-4345-94E7-57B0BA6F9169@.microsoft.com...[vbcol=seagreen]
>I was fiddling around with different connection strings and this one
>finally
> allowed me to connect: "Data Source=.\\SQLEXPRESS;Initial
> Catalog=TestDB;Integrated Security=SSPI;"
> "Frustrated" wrote:
>

No comments:

Post a Comment