Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Within 1 transaction you can only read/write to 1 connection until the transaction is done. Therefore you have to pass the connection object if you do a business transaction that spans several sql statements like this:</p> <pre><code>public class TimeTableService { ITimeTableDataProvider _provider = new TimeTableDataProvider(); public void CreateLessonPlanner(WizardData wizardData) { using (var con = _provider.GetConnection()) using (var trans = new TransactionScope()) { con.Open(); var weekListA = new List&lt;Week&gt;(); var weekListB = new List&lt;Week&gt;(); LessonPlannerCreator.CreateLessonPlanner(weekListA, weekListB, wizardData); _provider.DeleteLessonPlanner(wizardData.StartDate, con); _provider.CreateLessonPlanner(weekListA, con); _provider.CreateLessonPlanner(weekListB, con); _provider.DeleteTimeTable(TimeTable.WeekType.A, con); _provider.StoreTimeTable(wizardData.LessonsWeekA.ToList&lt;TimeTable&gt;(), TimeTable.WeekType.A, con); _provider.DeleteTimeTable(TimeTable.WeekType.B, con); _provider.StoreTimeTable(wizardData.LessonsWeekB.ToList&lt;TimeTable&gt;(), TimeTable.WeekType.B, con); trans.Complete(); } } } </code></pre> <p>The connection and transactoin resources are automatically released/closed by the using-statement.</p> <p>In every dataprovider method you then do</p> <pre><code>using(var cmd = new SQLiteCommand("MyStatement",con) { // Create params + ExecuteNonQuery } </code></pre> <p>The TransactionScope class is new in .NET 3.5 and is doing automatically a rollback if an exception occurs. Easy handling...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload