I am using sqlite in my compact framework application to log the events in system. I am also using System.Data.SQLite. The event has the time stamp to describe at what time it occurred. I am storing this Time stamp as Ticks in my table. Along with this column the table contains another 5 columns of integer/text type. Below is table schema
CREATE TABLE T1 (TimeStamp INTEGER, Col2 INTEGER, Col3 INTEGER, Col4 INTEGER,
Col5 INTEGER, Col6 TEXT, PRIMARY KEY(TimeStamp DESC));
I am querying for the data between two time stamp using ADO with below query
SELECT TimeStamp,Col1,Col2,Col3,Col4,Col5 FROM T1 WHERE TimeStamp
BETWEEN @startDate AND @endDate LIMIT 2000;
I am converting the Time stamp given by the user to Ticks and sending them as parameter values for '@startDate' and '@endDate'.
After I executed above query then I start iterating over SqLiteDataReader using while loop there I found that this while loop never comes out and continue to execute endlessly. Ideally it should end after reading 2000 records. Below is code snippet.
SQLiteDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
:
: Fill the data from column into Event class object
:
}
Please let me know if anybody has faced same issue.
EDIT :- After investigation I found that this problem comes up on fully loaded system. I simulate the environment of fully loaded system and tried on it.
You could always solve it in another way, eliminating the
LIMIT 2000
from the SQL and slightly changing your read logic like this: