all groups > sql server connect > november 2006 >
You're in the

sql server connect

group:

Local connection to SQL Server 2005 Express fails


Re: Local connection to SQL Server 2005 Express fails Arnie Rowland
11/29/2006 1:02:30 PM
sql server connect:
Perhaps these will help:

Configuration -Configure SQL Server 2005 to allow remote connections
http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

Configuration -Connect to SQL Express from "downlevel clients"
http://blogs.msdn.com/sqlexpress/archive/2004/07/23/192044.aspx


--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


[quoted text, click to view]

Local connection to SQL Server 2005 Express fails TAC
11/29/2006 3:49:38 PM
I just installed SQL Server 2005 Express edition, and created an app in
Visual Studio using C#. I get the following error when trying to connect:

"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)"

I enabled Named Pipes but left TCP/IP disabled because this is a localhost
connection on the same computer.

Here is the portion of the code I am using to connect:

string dbCString = "Persist Security Info=False;Integrated
Security=true;Trusted_Connection=true;Initial
Catalog=MxData;server=(local)";

SqlConnection ThisConnection = new SqlConnection(dbCString);

ThisConnection.Open();



Thanks in advance for any help.








Re: Local connection to SQL Server 2005 Express fails Arnie Rowland
11/30/2006 12:40:05 PM
This is a WAG:

You only need one of these two settings, perhaps having both is causing the
connection string to cause failure.

Integrated Security=true;Trusted_Connection=true;

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


[quoted text, click to view]

Re: Local connection to SQL Server 2005 Express fails TAC
11/30/2006 2:03:00 PM
Thanks for the info, but I did everything suggested in those two articles
and I still get the same connection error. I also tried various alterations
of my connection string with no success. Further research indicates that
this is a common problem, so I wonder why Microsoft ships the Express
edition along with Visual Studio 2005, but makes it so difficult to connect.

If you or anyone else has any other ideas, I would be most grateful.

Thanks.


[quoted text, click to view]

Re: Local connection to SQL Server 2005 Express fails TAC
11/30/2006 4:51:02 PM
Thanks for the suggestion, but using only one or the other didn't work,
either.


[quoted text, click to view]

Re: Local connection to SQL Server 2005 Express fails TAC
11/30/2006 6:13:11 PM
After a lot of research, here's the answer. The connection string should
read as follows:
"Server=.\\SQLEXPRESS;Initial Catalog=MxData;Integrated Security=SSPI";

Note that you need a dot followed by TWO left slashes in your server name.
BTW, Initial Catalog is whatever database you want to use.


[quoted text, click to view]

Re: Local connection to SQL Server 2005 Express fails Arnie Rowland
11/30/2006 6:51:13 PM
Thanks for following up your own post. It prevents others from wasting their
time trying to help you after you have solved the problem, and it helps
others when you share your solution.


--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


[quoted text, click to view]

AddThis Social Bookmark Button