none
System.Data.OleDb.OleDbException: Login timeout expired RRS feed

  • Question

  • Hello everyone, first post here

    This has been kicking me all day, I can't seem to connect to a remote (but in the office) SQL2000 Server from my c# windows application (Visual Studio 2005 so DotNet 2.0). Whenever I try I get an exceptiong within the code that reads

    Code Snippet

    e = {"Login timeout expired\r\nAn 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.\r\nNamed...


    A further stack trace reveals the following

    Code Snippet

    System.Data.OleDb.OleDbException: Login timeout expired
    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.
    Named Pipes Provider: Could not open a connection to SQL Server [53].
       at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
       at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.OleDb.OleDbConnection.Open()


    I'm pretty stuck as I can still connect to the DB using a classic ASP page, my connection string is as follows

    Code Snippet

    Provider=SQLNCLI;Server=sqlserver;Database=e2ecrm;Uid=****;Pwd=****;


    Friday, July 20, 2007 3:10 PM

All replies

  • First go to the SQL Server machine and review the latest errorlog.

    You can get location of errorlog by running:

     

    select serverproperty('ERRORLOGFILENAME')

     

    Open this in notepad and verify that the server is listening on either named pipes or tcp or both.

    Typically tcp is easier to work with because you have a known port.

     

    Now once you are sure it is listening, then on the server machine ensure Windows Firewall is allowing communication over this tcp port, you may need to add an exception for the port, see -> http://msdn2.microsoft.com/en-us/library/ms175043.aspx

     

    If you are trying to connect to a named instance you also need to open UDP 1434 port on Windows Firewall.

     

    Ok, once you are sure SQL is listening and firewall is open, go back to the client machine and try to connect again, should work.

     

    If it doesn't work, try specifying in the connection string the tcp prefix (to force tcp protocol) the server's ip and port like so:

     

    server=tcp:123.123.123.123,1433

     

    This will take out any ambiguity.

     

     

     

     

     

     

     

     

    Friday, July 20, 2007 4:58 PM