in

System.Data.SQLite

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

Passing SQLiteDataReader between classes.

Last post 07-06-2008 2:16 PM by Robert Simpson. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 07-04-2008 1:42 PM

    Passing SQLiteDataReader between classes.

     Hello,

    I am getting System.AccessViolationException when reading from instance of SQLiteDataReader passed to another class.

    Here is the situation:

    I have a class called TrustedApp and a static class TrustedAppsDal. I'm creating an instance of  TrustedApp class and calling its GetAll method which in turn calls TrustedAppsDal's static GetAll function. TrustedAppsDal's static GetAll function returns instance of SQLiteDataReader to GetAll method of TrsutedApp class. When invoking GetInt64() method I'm getting System.AccessViolationException. I'm getting same exception when calling any other Getxxx() method. However, invoking these methods in the static GetAll function works as expected.

     Any ideas?

    I know that I shouldn't be passing  instance of SQLiteDataReader between threads (and I'm not) but documentation doesn't say anything about passing between classes.

     Here is stacktrace:

       at System.Data.SQLite.UnsafeNativeMethods.sqlite3_column_type_interop(IntPtr stmt, Int32 index)
       at System.Data.SQLite.SQLite3.ColumnAffinity(SQLiteStatement stmt, Int32 index)
       at System.Data.SQLite.SQLite3.ColumnType(SQLiteStatement stmt, Int32 index, TypeAffinity& nAffinity)
       at System.Data.SQLite.SQLiteDataReader.GetSQLiteType(Int32 i)
       at System.Data.SQLite.SQLiteDataReader.VerifyType(Int32 i, DbType typ)
       at System.Data.SQLite.SQLiteDataReader.GetInt64(Int32 i)

  • 07-05-2008 10:38 PM In reply to

    Re: Passing SQLiteDataReader between classes.

    Weird.  What does your code look like that returns the datareader?  Are you opening a connection anywhere and closing it?

  • 07-06-2008 1:32 PM In reply to

    Re: Passing SQLiteDataReader between classes.

     Problem solved. The code that was returning open datareader was in using block which caused automatic disposian of connection.

     Thanks.

  • 07-06-2008 2:16 PM In reply to

    Re: Passing SQLiteDataReader between classes.

    I'll have to fix that code so it returns a proper error message instead of crashing.

Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems