Scenario
- encrpyted Sqlite database
- System.Data.SQlite.dll (version 1.0.97.9)
- .net framework 2.0
- x86
There is one thread for writing data to database, and several threads for reading data.
Table is created in next way:
CREATE TABLE [TableTransaction] (
[ID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[TOTALIN] DECIMAL(18, 4) DEFAULT 0
...
);
Code which is used for reading data:
using (DbCommand cmd = SQLiteFactory.Instance.CreateCommand())
{
SQLiteConnection cn = (SQLiteConnection)SQLiteFactory.Instance.CreateConnection();
cn.ConnectionString = "Data Source=myDatabase.db; Password=fdsh243ah45";
cn.Open();
cmd.CommandText = "SELECT * FROM TableTransaction";
cmd.CommandType = CommandType.Text;
cmd.CommandTimeout = 15;
cmd.Connection = cn;
using (DbDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
int id = reader.GetInt32("ID");
decimal totalIn = reader.GetDecimal("TOTALIN");
}
}
}
In database TOTALIN = 0.0001.
If I run this SELECT command from main thread, then I get totalIn = 0.00100000011920928 (wrong value).
But, if I run it from some other thread, then totalIn = 0.0001 (this value is ok).
I assume that there is some internal casting from decimal to double. But
why it happens only on main thread?
What could cause this behaviour?
I didn't
play with threads, all thread values are default values.