Hello,
I'm working on a batch read-only multi-threaded application using massively SQLiteDataReader. This application is working fine and very fast using System.Data.SQLite with basic connect String like "Data Source=..." and no optionnal settings. When changing drivers to last version of "dotConnect for Sqlite", keeping exactly the same code, and using 1 thread, the application is running as fine as it was running with System.Data.SQLite drivers.
Problems occurs when using more than 1 thread with dotConnect drivers while it's working fine with many thread and System.Data.SQLite drivers.
The error was still the same and appears randomly :
System.AccessViolationException was unhandled
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=Devart.Data.SQLite
StackTrace:
at Devart.Data.SQLite.bc.sqlite3_column_type(IntPtr A_0, Int32 A_1)
at Devart.Data.SQLite.a3.a(bs A_0, Int32 A_1, SQLiteType& A_2)
at Devart.Data.SQLite.SQLiteDataReader.c(Int32 A_0)
at Devart.Data.SQLite.SQLiteDataReader.GetSQLiteType(Int32 i)
at Devart.Data.SQLite.SQLiteDataReader.GetValue(Int32 i)
at Devart.Common.DbDataReaderBase.get_Item(String name)
...
Any help about this is welcome.
Thx in advance
Migrating from System.Data.SQLite to Devart.Data.SQLite
i've resolve my problem but it's a bit strange ...
explanation : most of my C# code querying SQLite was like this :
SQLiteCommand command = new SQLiteCommand(...);
command.CommandText = "SELECT * ...";
SQLiteDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
...
}
and changing it the next syntax resolve my problem :
SQLiteCommand command = new SQLiteCommand(...);
command.CommandText = "SELECT * ...";
SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())
{
...
}
reader.Close();
Can someone help me to understand why it was a problem to use the CommandBehavior.CloseConnection ?
Thx
explanation : most of my C# code querying SQLite was like this :
SQLiteCommand command = new SQLiteCommand(...);
command.CommandText = "SELECT * ...";
SQLiteDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
...
}
and changing it the next syntax resolve my problem :
SQLiteCommand command = new SQLiteCommand(...);
command.CommandText = "SELECT * ...";
SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())
{
...
}
reader.Close();
Can someone help me to understand why it was a problem to use the CommandBehavior.CloseConnection ?
Thx
You have to explicitly call the SQLiteDataReader.Close() method when you are finished using the SQLiteDataReader to use the associated SQLiteConnection for any other purpose (MSDN).
"CommandBehavior.CloseConnection - When the command is executed, the associated Connection object is closed when the associated DataReader object is closed." But you do not call reader.Close() in the first case.
Please refer to http://msdn.microsoft.com/en-us/library ... avior.aspx:lpg2000 wrote:Can someone help me to understand why it was a problem to use the CommandBehavior.CloseConnection ?
"CommandBehavior.CloseConnection - When the command is executed, the associated Connection object is closed when the associated DataReader object is closed." But you do not call reader.Close() in the first case.