Error opening connection

G

Guest

I'm having problem opening SqlConnection after MSDE reinstallation.

In the following snippet:

SqlConnection cnn = new System.Data.SqlClient.SqlConnection( );
cnn.ConnectionString = "Connect Timeout=30; Initial Catalog=master; Packet
Size=4096; Data Source=(local); User ID=sa; Password=abc"
cnn.Open( );

I'm getting exception -

'System.Data.SqlClient.SqlException'

Message:
'SQL Server does not exist or access denied.'

Call Stack:
at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransaction)
at
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()

Whne I added "Pooling=false;" to connection string call stack changed as
well -
Call Stack:
at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin()
at System.Data.SqlClient.SqlInternalConnection..ctor(SqlConnection
connection, SqlConnectionString connectionOptions)
at System.Data.SqlClient.SqlConnection.Open()

Any suggestions, please?

Thank you,
Eugene
 
S

Scott M.

I think your exception message says it all:

'SQL Server does not exist or access denied.'

Change Data Source=(local)

to

Data Source=(localhost)

-Scott
 
G

Guest

Hi Eugene,

I think that the problem may be either that the app cannot find (local) or
the login that is provided is incorrect. My suggestion is to try to
reference the Sql Server by name (or IP) and check and see if the credentials
that you have provided can log you in (by logging into Query Analyzer).

If this is not the problem please reply to this post so the group may help
you better.

I hope this helps.
------------------------------------
 
G

Guest

I should have been more specific.

I'm writing a MSDE installer. It uses 'MsiConfigureProduct' API to uninstall
old version and 'MsiInstallProduct' to install new one. After the installation
it programmatically starts MSSQLSERVER service. Up to this point everything
goes just fine. Next my program needs to open a connection to newly installed
MSDE to do some adjustments. And this is when the problem occurs.

I tried to use command line utility 'OSQL.exe' and it also failed to connect.
I guarantee that credentials are correct.

Restarting MSSQLSERVER service one more time programmatically does not help
either.
However restarting MSSQLSERVER service from administrative tools 'Services'
console does help. Once MSSQLSERVER service is restarted via ‘Services’ both
my
program and 'OSQL.exe' utility open connection without any difficulties.

Please help and thank you for your advice.

Eugene
 
G

Guest

Hi Eugene,

Sorry about the late reply... Since you have said that the app cannot
connect to the MSDE instance until you go into the service manager and start
it there the problem could lie in how the service is being started
programatically. Can you check
how you are starting the service against how the link to the document
below is starting the service to ensure that the service is starting
correctly? If this does not work for you can you please post a sample
program that will exibit the same type of problem? This would help quite a
bit.

I hope this helps.
---------------------------------

//link to document
http://www.gotdotnet.com/Community/...mpleGuid=8EB91573-C520-4143-9323-77904FE02CAF

//configuration link
http://www.codeproject.com/database/ConfigureMSDE.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top