All,

In the following bit of code found in the help file SQLite.NET.chm, I see that BeginTransaction() encloses everything. I always thought that just the for-loop needed to be enclosed by begin/commit.

What are the reasons for enclosing the other commands?

Thanks,
-Bill



using (SQLiteTransaction mytransaction = myconnection.BeginTransaction())
      {
using (SQLiteCommand mycommand = new SQLiteCommand(myconnection))
        {
          SQLiteParameter myparam = new SQLiteParameter();
          int n;

mycommand.CommandText = "INSERT INTO [MyTable] ([MyId]) VALUES(?)";
          mycommand.Parameters.Add(myparam);

          for (n = 0; n < 100000; n ++)
          {
            myparam.Value = n + 1;
            mycommand.ExecuteNonQuery();
          }
        }
        mytransaction.Commit();
      }
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to