title: Dependable insert with SQLite
body: <p>I'm writing a program in C# that needs to insert data in multiple tables. The first insert returns a last insert rowid, which is in turn used to perform an insert on the other tables. In pseudo code:</p>
  
  <pre><code>INSERT INTO TableFoo (Col2, Col3, Col4, etc.) VALUES (@Bla2, @bla3, @bla4);
  </code></pre>
  
  <p>Immediately after this insert I get the last insert id by:</p>
  
  <pre><code>SELECT last_insert_rowid() AS RowId;
  </code></pre>
  
  <p>I retrieve the RowId column in a datareader and store it in an int "RowId". 
  Finally I insert some more tables like:</p>
  
  <pre><code>INSERT INTO TableBar (FooId, Col2) VALUES (RowId, @BSomeMoreBla)");
  </code></pre>
  
  <p><strong>The question</strong>: If possible, I want to perform this bunch of inserts (and a select RowId) in 1 transaction to prevent some half-saved data. Is it possible to use a transaction in this scenario and what would be the preferred way?</p>
  
  <p>A SQLite transaction?
  C#'s System.Transactions namespace?
  A third way to perform an atomic database multi-insert...?</p>