Home All Groups Group Topic Archive Search About

SQL connection error in ASP.NET only (WinForms ok)

Author
13 Oct 2006 10:01 AM
pearcz
Hallo,
I have this perplexing problem. On my development machine, sql connections
in ASP.NET pages debugged in both Visual Studio 2003 (ASP.NET 1.1.) and
Visual Studio 2005 (ASP.NET 2.0.) stopped working. I suspect the cause is one
of microsft updates which I apply as they are published. I am trying to
connect to a remote sql server via sql authentication. I have no problems
connecting using the same code in WinForm application, which means connection
string is correct.
Our company has ISA server 2004 and monitoring communication with the remote
server, funny things happen: when connecting from WinForms, destination port
is 1433 but when from ASP.NET, I can see number of attempts to connect to
ports 137, 139 (netbios) and 445 (microsoft CIFS). I googled and added
Network Library=dbmssocn to connection string to make it connect through
TCP/IP, but to no avail.
Any idea WTF is going on?
Thanks for replies
Pavel

Sample code:

Dim oconn As New System.Data.SqlClient.SqlConnection("Data
Source=xxx.xxx.xxx.xxx;User ID=sa;Password=test;Initial Catalog=ck;")

        Try
            oconn.Open()
        Catch ex As Exception
            System.Diagnostics.Debug.WriteLine(ex.ToString())
        Finally
            If Not oconn Is Nothing Then
                If oconn.State = ConnectionState.Open Then
                    oconn.Close()
                End If
                oconn = Nothing
            End If
        End Try

Exception info:

A first chance exception of type 'System.Data.SqlClient.SqlException'
occurred in System.Data.dll
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: TCP Provider, error: 0 - A socket
operation encountered a dead network.)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
   at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
   at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner,
Boolean& failoverDemandDone, String host, String failoverPartner, String
protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean
encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection
owningObject, Boolean aliasLookup)
   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 debug3.Page_Load(Object sender, EventArgs e) in
D:\PRODUCTS\_shared\web_booking\debug3.aspx.vb:line 16

AddThis Social Bookmark Button