Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can't connect to SQL Server 2008

8 views
Skip to first unread message

larzeb

unread,
Nov 30, 2009, 1:50:01 PM11/30/09
to

The SQL Server 2008 is, and has been, running on Windows 2008 Server. I had a
client development machine running Vista 32-bit/VS2008 which could access
this server.

I wiped that client machine and loaded Windows 7 64-bit and VS2008. Now my
VS solution cannot connect to the SQL Server. It times out.

I can access the database in question from VS2008 and retrieve via "Show
Table Data" from with Server Explorer.

So I am very confused. Can anyone help?

Thanks Charles

Connection string:
Data Source=POWDB;Initial Catalog=DbName;Persist Security Info=True;User
ID=user;Password=password

Error Message:
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
at
System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject
stateObj, UInt32 error)
at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult
asyncResult, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
at System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt,
Boolean trustServerCert, Boolean& marsCapable)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo,
SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64
timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean
integratedSecurity, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64
timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String
host, String newPassword, Boolean redirectedUserInstance, SqlConnection
owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection
owningObject, SqlConnectionString connectionOptions, String newPassword,
Boolean redirectedUserInstance)
at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, Object providerInfo, String
newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
owningConnection)
at
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection
owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection
owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at MailHouse.DataAccess.Client.GetEntityAll() in
E:\Development\Mailhouse\MailHouse.DataAccess\DB\Client.vb:line 282
at MailHouse.Forms.Login.Login_Load(Object sender, EventArgs e) in
E:\Development\Mailhouse\MailHouse.Forms\Login.vb:line 30

Erland Sommarskog

unread,
Nov 30, 2009, 5:21:50 PM11/30/09
to
larzeb (lar...@discussions.microsoft.com) writes:
> The SQL Server 2008 is, and has been, running on Windows 2008 Server. I
> had a client development machine running Vista 32-bit/VS2008 which could
> access this server.
>
> I wiped that client machine and loaded Windows 7 64-bit and VS2008. Now my
> VS solution cannot connect to the SQL Server. It times out.
>
> I can access the database in question from VS2008 and retrieve via "Show
> Table Data" from with Server Explorer.
>
> So I am very confused. Can anyone help?
>
> Thanks Charles
>
> Connection string:
> Data Source=POWDB;Initial Catalog=DbName;Persist Security Info=True;User
> ID=user;Password=password
>
> Error Message:

All there is in the error message is a stack dump. Wasn't there an actual
message?

But you can access the server from within Visual Studio. However, it
does not work from your application? I guess you need to compare the
connection string with the connection properties for what you have in
Server Explorer.

And if you can find the actual error message, post it.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

larzeb

unread,
Dec 1, 2009, 9:26:03 AM12/1/09
to
Thanks for the response, Erland.

The error occurs on opening a connection. I've included some more
information from the debugger. It's a timeout.

The connection string from Server Explorer is the same as I'm using in code.
I can connect to SQL Server 2008 using sqlcmd from the same machine which
runs VS2008! When I connect via sqlcmd, I use the same user/password.

Very confused.

Lars

Connection string:
Data Source=POWDB;Initial Catalog=DbName;Persist Security Info=True;User
ID=user;Password=password

From client machine running VS2008, which gets accurate output:
C:\>sqlcmd -SPOWDB -Uuser -Ppassword -dDbName -Q"select * from client;"

From client machine running VS2008, which gets accurate output:
C:\>sqlcmd -SPOWDB -Uuser -Ppassword -dDbName
1> EXEC dbo.usp_client_sel_all
2> go

From VS2008:
Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding.

Looping through the SqlException in a catch block:
A first chance exception of type 'System.Data.SqlClient.SqlException'
occurred in System.Data.dll
Index #0
Message: Timeout expired. The timeout period elapsed prior to completion of
the operation or the server is not responding.
LineNumber: 0
Source: .Net SqlClient Data Provider
Procedure:

From the SqlException:
ErrorCode -2146232060 Integer
Number -2 Integer

{System.Data.SqlClient.SqlCommand}
CommandText: "usp_Client_Sel_All"
CommandTimeout: 30
CommandType: StoredProcedure {4}
Connection: {System.Data.SqlClient.SqlConnection}
Container: Nothing
DesignTimeVisible: True
Notification: Nothing
NotificationAutoEnlist: True
Parameters: {System.Data.SqlClient.SqlParameterCollection}
Site: Nothing
Transaction: Nothing
UpdatedRowSource: Both {3}


"Erland Sommarskog" wrote:

> .
>

Will Alber

unread,
Dec 1, 2009, 5:35:12 PM12/1/09
to
Hi Lars,

Does this stored procedure get called very early on in the lifetime of your
application? Are there other routines that are callled that are working?

I'm just wondering if this is a VS connection pooling issue - you can get
timeouts (albeit typically with a different error message that the below) if
you e.g. forget to close connections on SQLConnection objects.

"larzeb" <lar...@discussions.microsoft.com> wrote in message
news:CDE9EB6A-8D24-48F7...@microsoft.com...

> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 4652 (20091201) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4652 (20091201) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


Erland Sommarskog

unread,
Dec 1, 2009, 5:40:16 PM12/1/09
to
larzeb (lar...@discussions.microsoft.com) writes:
> The error occurs on opening a connection. I've included some more
> information from the debugger. It's a timeout.
>
> The connection string from Server Explorer is the same as I'm using in
> code. I can connect to SQL Server 2008 using sqlcmd from the same
> machine which runs VS2008! When I connect via sqlcmd, I use the same
> user/password.

I will have to admit that I'm stumped. Apparently something is not
what it seems to be.

The error message looks more like a command timeout to me, but the stack
dump indicates a connection problem.

I would use Profiler and include all Security Audit events, and see if
something turns up.

Amaral@discussions.microsoft.com Ricardo Amaral

unread,
Jan 11, 2010, 5:40:01 PM1/11/10
to
Hi,

I'm seeing the same thing with 7x64, VS 2005 and SQL express 2005. I can
connect from the IDE but the application falis to connect remotelly via
TCP/IP. A local connection from the same application works just fine. The
rror is something like login failed or sever does not exist. Tryied running
both from VSHOST and complied.

Any help will be appreciated.

Ricardo

"Erland Sommarskog" wrote:

> .
>

William Vaughn (MVP)

unread,
Jan 12, 2010, 4:35:11 PM1/12/10
to
Did you disable the firewall? Do you know what port is being used by the SQL
Server instance? Did you make sure the TCP/IP option is enabled on the
server and restarted it? Did you make sure the SQL Browser service is
started?

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com http://betav.com/blog/billva
____________________________________________________________________________________________

"Ricardo Amaral" <Ricardo Ama...@discussions.microsoft.com> wrote in message
news:4700CB67-0A14-44BE...@microsoft.com...

Erland Sommarskog

unread,
Jan 12, 2010, 5:12:18 PM1/12/10
to
Ricardo Amaral (Ricardo Ama...@discussions.microsoft.com) writes:
> I'm seeing the same thing with 7x64, VS 2005 and SQL express 2005. I can
> connect from the IDE but the application falis to connect remotelly via
> TCP/IP. A local connection from the same application works just fine.
> The rror is something like login failed or sever does not exist. Tryied
> running both from VSHOST and complied.

By default SQL Express does not accept remote connections. You can
change this in SQL Server Surface Area tool, or in SQL Server Configuration
Manager.

Also make sure that the Browser service is running in SQL Server
Configuration Manager.

Also, as Bill says, you must also make sure you permit connections through
the firewall. This includes the TCP port on which SQL Server is running,
but also UDP port 1434 on which SQL Server Browser is listening.

0 new messages