Store Pilots

SimpleExamples.cs: StorePilots
01private static void StorePilots() 02 { 03 File.Delete(Db4oFileName); 04 IObjectContainer container = Database(); 05 if (container != null) 06 { 07 try 08 { 09 Pilot pilot; 10 for (int i = 0; i < ObjectCount; i++) 11 { 12 pilot = new Pilot("Test Pilot #" + i, i); 13 container.Set(pilot); 14 } 15 for (int i = 0; i < ObjectCount; i++) 16 { 17 pilot = new Pilot("Professional Pilot #" + (i + 10), i + 10); 18 container.Set(pilot); 19 } 20 container.Commit(); 21 } 22 catch (Db4oException ex) 23 { 24 System.Console.WriteLine("Db4o Exception: " + ex.Message); 25 } 26 catch (Exception ex) 27 { 28 System.Console.WriteLine("System Exception: " + ex.Message); 29 } 30 finally 31 { 32 CloseDatabase(); 33 } 34 } 35 }
SimpleExamples.vb: StorePilots
01Private Shared Sub StorePilots() 02 File.Delete(Db4oFileName) 03 Dim container As IObjectContainer = Database() 04 If Not container Is Nothing Then 05 Try 06 Dim pilot As Pilot 07 Dim i As Integer 08 For i = 0 To ObjectCount - 1 Step i + 1 09 pilot = New Pilot("Test Pilot #" + i.ToString(), i) 10 container.Set(pilot) 11 Next 12 i = 0 13 For i = 0 To ObjectCount - 1 Step i + 1 14 pilot = New Pilot("Professional Pilot #" + (i + 10).ToString(), i + 10) 15 container.Set(pilot) 16 Next 17 container.Commit() 18 Catch ex As Db4oException 19 System.Console.WriteLine("Db4o Exception: " + ex.Message) 20 Catch ex As Exception 21 System.Console.WriteLine("System Exception: " + ex.Message) 22 Finally 23 CloseDatabase() 24 End Try 25 End If 26 End Sub