Knight Data Access Layer
CommitTransaction Method (IDataHelper)
Example 




KellermanSoftware.NetDataAccessLayer Namespace > IDataHelper Interface : CommitTransaction Method
Commit the current transaction
Syntax
Sub CommitTransaction() 
Dim instance As IDataHelper
 
instance.CommitTransaction()
void CommitTransaction()
void CommitTransaction(); 
void CommitTransaction(); 
Example
//Get the current thread static safe instance of the helper
IDataHelper db = DataHelper.SessionFactory();
 
//Specify User Name and License Key from the receipt, leave blank for trial mode
//db.UserName = "John Smith 1234";
//db.LicenseKey = "asdfl219==";
 
//Log to the console
db.EnableLogging();
 
//Fill in the maintenance Fields
db.FillInMaintenanceFields = true;
 
//Open the database connection
db.OpenConnection();
 
//Begin a transaction to save two people at once
 
db.BeginTransaction();
 
//Create a new Person to save to the database
Person person1 = new Person();
person1.FirstName = "John";
person1.LastName = "Smith";
 
//Save it to the database (see the SQL in the console)
db.Save(person1);
 
//Create another new Person to save to the database
Person person2 = new Person();
person2.FirstName = "Jane";
person2.LastName = "Smith";
 
//Save it to the database (see the SQL in the console)
db.Save(person2);
 
//This will be true
Console.WriteLine(db.IsInTransaction);
 
//Commit the transaction
db.CommitTransaction();
 
//This will be false
Console.WriteLine(db.IsInTransaction);
 
//Close the connection
db.CloseConnection();
'Get the current thread static safe instance of the helper
Dim db As IDataHelper = DataHelper.SessionFactory()
 
'Specify User Name and License Key from the receipt, leave blank for trial mode
'db.UserName = "John Smith 1234"
'db.LicenseKey = "asdfl219=="
 
'Log to the console
db.EnableLogging()
 
'Fill in the maintenance Fields
db.FillInMaintenanceFields = True
 
'Open the database connection
db.OpenConnection()
 
'Begin a transaction to save two people at once
 
db.BeginTransaction()
 
'Create a new Person to save to the database
Dim person1 As New Person()
person1.FirstName = "John"
person1.LastName = "Smith"
 
'Save it to the database (see the SQL in the console)
db.Save(person1)
 
'Create another new Person to save to the database
Dim person2 As New Person()
person2.FirstName = "Jane"
person2.LastName = "Smith"
 
'Save it to the database (see the SQL in the console)
db.Save(person2)
 
'This will be true
Console.WriteLine(db.IsInTransaction)
 
'Commit the transaction
db.CommitTransaction()
 
'This will be false
Console.WriteLine(db.IsInTransaction)
 
'Close the connection
db.CloseConnection()
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IDataHelper Interface
IDataHelper Members