title: ODBC Oracle Error
body: <p>I have a .net App I have been asked to modify, it uses .net framework 2.0</p>
  
  <p>I have setup an ODBC DSN with the connection details for our Oracle DB on my local machine, Tested the connection and it works fine.</p>
  
  <p>Now I ran my application, it went with no problem and finished, I had checked our error log and found a couple of errors unrelated to this issue but this error did not show up.</p>
  
  <p>So I ran the app again with break points in order to get to these errors.  This time it crashed with the below error</p>
  
  <blockquote>
    <p>ERROR [IM004] [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle
    on SQL_HANDLE_ENV failed</p>
  </blockquote>
  
  <p>Now what is getting me on this is that it just ran fine not even 10 minutes ago and I only added a break point.</p>
  
  <p>I have found a few answers and gave them all a shot.</p>
  
  <ol>
  <li>I set the Read/Execute on the oracle driver folder off than on to reset the permissions and it made no difference</li>
  <li>I checked the "Path" Environment Variable and it is fine</li>
  <li>Using the ODBC Administrator I tested the connection without error.</li>
  <li>Verified the connection string pointing to the DSN is still correct 5. List item</li>
  <li>Verified my App is setup to run 32 bit as the Driver is 32 bit.</li>
  </ol>
  
  <p>The only thing I have not done is to save, shut restart computer and try again.. Which I will do right after this post, if it works I will post that.</p>
  
  <p>Anyway if anyone has any idea what could cause this behaviour I would be very thankful to you.</p>
  
  <p>Computer is Win7, .net FrameWork is 2.0 , it's VB.net, Oracle Driver is 10g (10.2)</p>
  
  <p>Update:
  okay I used the ODBC Administrator to remove the DSN and rebuild it.  I ran my app and it worked.</p>
  
  <p>I came back later today after no changes and re-ran the application and got the error again.  tried to rebuild the DSN and it didn't help, I tried to restart and it didn't help.</p>
  
  <p>Below is the stack trace.</p>
  
  <pre><code>StackTrace:
         at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
         at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
         at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
         at System.Data.Odbc.OdbcConnectionFactory.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.Odbc.OdbcConnection.Open()
  </code></pre>