in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

SQLiteDataReader closes connection before the command?

Last post 05-15-2008 7:52 AM by Sam_. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-14-2008 8:57 PM

    • Sam_
    • Top 10 Contributor
    • Joined on 02-13-2007
    • Washington DC
    • Posts 86

    SQLiteDataReader closes connection before the command?

    I'm looking into access violations we get when disposing commands and noticed that in SQLiteDataReader's Close() method it closes the connection before it closes the command.

     

            // If the datareader's behavior includes closing the connection, then do so here.
            if ((_commandBehavior & CommandBehavior.CloseConnection) != 0 && _command.Connection != null)
              _command.Connection.Close();

            if (_disposeCommand)
              _command.Dispose();

    shouldn't that be the other way around? Close the command first?

            SQLiteConnection cnn = _command.Connection;

            if (_disposeCommand)
              _command.Dispose();

            // If the datareader's behavior includes closing the connection, then do so here.
            if ((_commandBehavior & CommandBehavior.CloseConnection) != 0 && cnn != null)
              cnn.Close();

     

    Thanks, Sam

    We're hiring! B-Line Medical is seeking .NET Developers for exciting positions in medical product development in MD/DC. Work with a variety of technologies in a relaxed team environment. See ads on http://careerbuilder.com.
  • 05-15-2008 7:52 AM In reply to

    • Sam_
    • Top 10 Contributor
    • Joined on 02-13-2007
    • Washington DC
    • Posts 86

    Re: SQLiteDataReader closes connection before the command?

    After making the above change we were able to start disposing SQLiteCommand objects and have not gotten any access violations (which we did get previously when disposing commands--that's why we stopped calling Dispose on commands).

    Thanks,

    Sam 

    We're hiring! B-Line Medical is seeking .NET Developers for exciting positions in medical product development in MD/DC. Work with a variety of technologies in a relaxed team environment. See ads on http://careerbuilder.com.
Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems