views:

172

answers:

2

I have a C# application that connects to a named SQL Express instance on the local machine using OleDBConnection:

_connection = new OleDbConnection(_strConn);
_connection.Open();

_strConn is something like this: "Provider=sqloledb;Data Source=.\NAMEDINSTANCE;Initial Catalog=dbname;User Id=sa;Password=password;"

If I debug the application, the connection works fine. If I run the application from Windows Explorer (the same debug compilation), I get an "OleDBException: Login timeout expired" in the Open() line after 30 seconds. The strange thing is the exception happens even if I attach the debugger to the exe. I can see that the connection string is correct and everything seems fine. I can't fine any extra information in the SQL Express error log or SQL Activity Monitor either.

If it helps, here is the exception:

    System.Data.OleDb.OleDbException: Login timeout expired
   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 imagine that find the issue with the information I give here might be difficult, but I don't know where else to look or what other tests to do, so any ideas on what it could be or what test I could do to find out will be really appreciated.

A: 

I fixed it. Unfortunately I don't really know how: I deleted the output folder, reset some project references, reconfigured several things on SQL Express, restarted the machine, etc. At some point, it started working fine again. It still annoys me not being able to discover what OleDb was doing for 31 seconds when connecting, but the problem is gone now (so far).

Thanks for your help.

Francesc
A: 

Hi!

I'm sorry to bother you, especially since you fixed it somehow. I'm facing the exact same issue, and it's driving me insane. Works through the debugger and not through the executable.

If you can recall anything about how you solved it, I would be most grateful.

My question is posted here : http://stackoverflow.com/questions/3298104/oracle-instant-client-c-tns-connect-timeout-occurred-only-through-install

Thanks! Sreedevi.

Sreedevi J