OleDB connection only working when debugging
Posted
by Francesc
on Stack Overflow
See other posts from Stack Overflow
or by Francesc
Published on 2010-05-28T11:19:56Z
Indexed on
2010/05/28
11:21 UTC
Read the original article
Hit count: 275
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.
© Stack Overflow or respective owner