I've read all the posts concerning this exception and all of them telling that the problem is in shared use of connection between diferent threads.... In my case this is a single thread application, i'm using no timers, no backgroundwarkers, no extra threads at all, everything happens in main thread... i just want to fetch all records where some condition is true, but get the exception at ExecuteReader.
Here is the call stack:
System.Data.SQLite.SQLiteException was unhandled
Message="Library used incorrectly\r\nlibrary routine called out of sequence"
StackTrace:
bij System.Data.SQLite.SQLite3.Bind_Int64(SQLiteStatement stmt, Int32 index, Int64 value)
bij System.Data.SQLite.SQLiteStatement.BindParameter(Int32 index, SQLiteParameter param)
bij System.Data.SQLite.SQLiteStatement.BindParameters()
bij System.Data.SQLite.SQLiteCommand.GetStatement(Int32 index)
bij System.Data.SQLite.SQLiteDataReader.NextResult()
bij System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
bij System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
bij System.Data.SQLite.SQLiteCommand.ExecuteReader()
bij Postron.Model.LookupItemAdapter.Fetch(Int64 lookupId)
bij MyTouch.MyTouchManager.BeginLookupItemReader(Int64 lookupId)
bij MyTouch.LookupScreen.OnPopulate()
bij Postron.UI.FormEnhanced.Populate()
bij MyTouch.LookupScreen.ShowLookup(Int64 lookupId, Int32 quantity)
bij MyTouch.ProductGrid.GridButtonClick(Object sender, EventArgs e)
bij System.Windows.Forms.Control.OnClick(EventArgs e)
bij System.Windows.Forms.Control.WnProc(WM wm, Int32 wParam, Int32 lParam)
bij System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
bij Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
bij System.Windows.Forms.Application.Run(Form fm)
bij MyTouch.Program.Main(String[ args)
Here is the code where the exception raises:
public SQLiteDataReader Fetch(long lookupId)
{
this.fetchByLookupCmd.Parameters[0].Value = lookupId;
return this.fetchByLookupCmd.ExecuteReader();
}
SQLiteCommand is initialized in ctor:
this.fetchByLookupCmd = new SQLiteCommand("SELECT * FROM LookupItem WHERE LookupID = @LookupID", this.Connection);
this.fetchByLookupCmd.Parameters.Add(new SQLiteParameter("@LookupID", DbType.Int64, "LookupID"));
Thanks in advance for helping me solving this issue!