1 Reply Latest reply on Jul 18, 2006 10:14 AM by 523618

    crash when creating connections

    523618
      I am using visualStudio.NET 2003.

      I have a single table in Oracle which contains several hundred rows one row contains a date field.

      I am attempting to select groups of rows by search for date ranges.

      I am achieving this by setting up and opening a connection (Successful on first attempt)
      Sending a simple select query to the DB.
      Reading the results,
      Closing the connection, reader and command using the dispose methods.

      Create a new query string, open a new connection read the results etc.

      The first connect and read works.
      The second connect simply crashes out of the procedure. No exception thrown and no obvious clues in the local variables windows on Visual studio.

      I have re-organized code in all sorts of ways. Sometimes it crashes out on the attempt to create a connection. On other attempts it crashes out on attempts to execute the reader.

      What am I doing wrong.

      If I halt the program loop after the methods to close the connections, Oracle is showing an active connection. But subsequent method calls on the old Oracle Connection reference indicate the instance is not instantiated.
        • 1. Re: crash when creating connections
          523618
          public LocColl findBus(System.DateTime lt, System.DateTime lt2, int busId)
               {
                                   
               try
               {
               Oracle.DataAccess.Client.OracleConnection dbConnection = new
          Oracle.DataAccess.Client.OracleConnection("User ID=guest;
          Password=user; Data Source = XE; ");     
               dbConnection.Open();
                                   

               long ltAccess = ((lt.Ticks/tickRatio) + 41380);
               long lt2Access = ((lt2.Ticks/tickRatio) + 41380);
                              
               string commandString = "SELECT LocationTime, Latitude,
          Longitude, BusIdentity FROM BusLocations WHERE
          (((BusLocations.LocTimeTicks) >= " + ltAccess + ") AND
          ((BusLocations.LocTimeTicks) <= " + lt2Access + ") AND
          ((BusLocations.BusIdentity) = " + busId + "))";
                              
               command = new Oracle.DataAccess.Client.OracleCommand
          (commandString, dbConnection);
                         

               localReader = command.ExecuteReader();
          locArray = readDbReturn(localReader); // This processes the
          results

               commandString = "SELECT LocationTime, Latitude, Longitude,
          BusIdentity FROM guest.BusLocations";
               command.CommandText = commandString;
               command.CommandType = CommandType.Text;
               localReader = command.ExecuteReader(); // At this point the
          debugger crashes out!
          Execution continues
          from the calling
          procedure.

               localReader.Dispose();
               command.Dispose();
          dbConnection.Close();          
               Oracle.DataAccess.Client.OracleConnection.ClearPool
          (dbConnection);
                              
               }
               catch(OracleException ex)
               {
               Console.WriteLine("Oracle Error = accessing the database: " + ex.Message);
               }
               catch(Exception e)
               {
               Console.WriteLine("Error = accessing the database: " + e.Message);
               }
               finally
               {
               dbConnection.PurgeStatementCache();
               dbConnection.Dispose();     
               dbConnection.Close();
               }
               return locArray;
          }