all groups > sql server connect > january 2007 >
You're in the

sql server connect

group:

VB Express can't connect to anything


VB Express can't connect to anything Birk Binnard
1/14/2007 4:18:31 PM
sql server connect:
I installed the latest version of VB Express & SQL Express with no
trouble. VB fails to connect to any database -- even the sample
applications fail with an SQL Exception:

System.Data.SqlClient.SqlException was unhandled
Class=20
ErrorCode=-2146232060
LineNumber=0
Message="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)"
Number=2
Server=""
Source=".Net SqlClient Data Provider"
State=0

Since everything is on my local PC why would there be a reference to
remote connections?

I'm sure this is something simple -- but what?

Thanks

Re: VB Express can't connect to anything Plamen Ratchev
1/14/2007 10:39:42 PM
Hi Birk,

By default Named Pipes and TCP/IP protocols are disabled. Only the Shared
Memory protocol is enabled. Also, SQL Server 2005 Express installs as a
named instance SQLEXPRESS. Make sure you specify it correctly in your
connection string. It should be something like this:

"Provider=SQLNCLI;Server=<MachineName>\SQLEXPRESS;Initial
Catalog=master;Integrated Security=SSPI "

In the above <MachineName> could be ".", "(local)","localhost", or
"<localhostname>".

Here are some steps for troubleshooting connectivity for SQL Server 2005
Express:
http://blogs.msdn.com/sql_protocols/archive/2006/03/23/558651.aspx

If you need to enable remote connections (it applies also to enabling the
Named Pipes and TCP/IP protocols for local connections) you can see this KB
article:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

Regards,

Plamen Ratchev
http://www.SQLStudio.com


[quoted text, click to view]

Re: VB Express can't connect to anything Birk Binnard
1/15/2007 8:29:08 AM
Thanks, but after several hours of reading and experimentation I am
still unable to get VBExpress to run any application that uses any SQL
database. Even the DVD Collection template fails to run properly -- it
starts and ends with no screen output at all.

My original objective was to convert an old Access application to a
stand-alone EXE that would be easily portable (and saleable) to clients
with no software installed other than regular Office. I initially tried
to get VBExpress to connect to my Access MDB file, but was unable to do
this (the dialog box that builds the connect string doesn't work.) So I
thought I'd try SQLExpress figuring VB needed something that was .Net
compliant.

After this experience its clear I'd be much better off converting the
Access tables to plain old VB data files. That way my app will be
independent of other software and I'll be able to ensure it will install
and work OK the first time.

It does seem odd that MS would allow "sample" software to be distributed
that in fact does not work immediately following installation. The fact
that there are KB articles explaining how to make things work is
shocking. I know that if I tried to put software like this in a
client's environment I'd be out of business in no time.
--
Birk Binnard
Re: VB Express can't connect to anything Plamen Ratchev
1/15/2007 12:49:03 PM
Hi Birk,

If you are distributing SQL Server 2005 Express with your software then you
can fully configure all options to allow remote connections at setup. Really
no need for your users to do anything manually. Just look up the
DISABLENETWORKPROTOCOLS option in the following articles:
http://blogs.msdn.com/sqlexpress/archive/2006/09/20/configuring-sql-express-during-installation.aspx
http://msdn2.microsoft.com/en-us/library/ms144259.aspx
http://msdn.microsoft.com/msdnmag/issues/04/10/bootstrapper/

In my opinion it is a good idea to disable remote access by default. That
helps to improve security.

As for the problems with your connection you can check the Windows event log
and the SQL Server log files for any error messages. Also, try connecting
with the SQL Server Management Studio to see if it will work.

Regards,

Plamen Ratchev
http://www.SQLStudio.com


[quoted text, click to view]

AddThis Social Bookmark Button