0 Replies Latest reply on Aug 17, 2004 1:45 PM by 427840

    ODatabase::Close raise AccessViolation

    427840
      I get access violoation when calling ODatabase::Close() duing debug mode with under MSVC 6.0 IDE.

      Someone mentioned in another thread that his problem is fixed by clearing the parameter collection before calling Close(). I have done this in the code below. Am I doing this wrong?

      Thanks in advance.

      #include "oracl.h"
      #include <string>
      #include <iostream>

      //------------------------------------------------------------------
      int main( int argc, char ** argv )
      {
      try
      {
      //----------------------------------------
      std::cout << "Initialising..." << std::endl ;
      //----------------------------------------
      OStartup( OSTARTUP_APARTMENTTHREADED ) ;
      //----------------------------------------
      ODatabase db_ ;
      //----------------------------------------
      std::cout << "Connecting..." << std::endl ;
      //----------------------------------------
      db_.Open( "ORFLND09", "", "" ) ;
      //----------------------------------------
      std::cout << "Disconnecting..." << std::endl ;
      //----------------------------------------
      if( db_.IsOpen() == TRUE )
      {
      OParameterCollection params = db_.GetParameters() ;

      for( int count = 0; count < params.GetCount(); ++count )
      params.Remove( count ) ;

      db_.Close() ;
      }
      }
      catch( const OException & x )
      {                                                                                  
      std::cout << "Exception :" << x.GetFailedMethodName() << " Error: "<< x.GetErrorText() << std::endl ;
      }
      catch(...)
      {
      std::cout << "Unknown exception" << std::endl ;
      }
      //---------------------------------------
      return 0 ;
      }