Page 1 of 1

An abnormal ThreadAbortException during multi insert

Posted: Mon 11 Jan 2010 12:20
by virgile
Hi,

I'm facing a odd problem during an insert operation on SQLite. My program is based on Quartz.net and SQLite to make statistics at scheduled times.

But during the insert operations the thread is stopped without error excepted an ThreadAbortException exception. I tried to identify the problem with debug mode but the exception is thrown anywhere in the below method.

Code: Select all

public void ExecuteNonQuery(DbQuery[] queries)
        {
            using (SQLiteConnection connexion = new SQLiteConnection("Data Source=" + absolutepath))
            {
                connexion.Open();

                using (SQLiteTransaction dbTrans = connexion.BeginTransaction(System.Data.IsolationLevel.ReadCommitted))
                {
                    try
                    {
                        foreach (DbQuery query in queries)
                        {
                            SQLiteCommand mycommand = connexion.CreateCommand();
                            mycommand.Connection = connexion;
                            mycommand.Transaction = dbTrans;
                            mycommand.CommandText = query.sql;
                            mycommand = this.InjectParameters(query.parameters, mycommand);
                            mycommand.ExecuteNonQuery();
                        }
                        dbTrans.Commit();
                    }
                    catch (Exception exc)
                    {
                        dbTrans.Rollback();
                    }
                    finally
                    {
                        connexion.Close();
                    }
                }
            }
        }

Posted: Wed 13 Jan 2010 16:01
by StanislavK
Please ensure that you don't use the non-thread-safe SQLiteConnection component within multithreading environment. ThreadAbortException most probably indicates such a situation.

Otherwise, please send us a small test project reproducing the problem, including the database file and the exact text of insert commands.