1
Vote

How to use the transaction?

description

I'm having an issue when I want to insert some datas.
When I want to add 3 articles, the 2 first are inserted but at the 3rd one an "SQLiteException' is thrown without any innerException.

It seems like the connection is lost after the 2nd one.
            var article = new Article
            {
                ArticleName = "test",
                ArticleCode = "321",
                ArticleFeature = "true blue",
                ArticlePrice = 33.22m,
                ArticleQuantity = 15,
                ArticleBarcode = TheReaderData.Text
            };
            var article2 = new Article
            {
                ArticleName = "test",
                ArticleCode = "321",
                ArticleFeature = "true blue",
                ArticlePrice = 33.22m,
                ArticleQuantity = 15,
                ArticleBarcode = TheReaderData.Text
            };
            var article3 = new Article
            {
                ArticleName = "test",
                ArticleCode = "321",
                ArticleFeature = "true blue",
                ArticlePrice = 33.22m,
                ArticleQuantity = 15,
                ArticleBarcode = TheReaderData.Text
            };

                store.Insert(article);
                store.Insert(article2);
                store.Insert(article3);  // <- Exception here
I tried to use the BeginTransaction() method but I also have an exception which is "transaction is not associated with the command's connection"

Can you explain how we can use it please?

comments