1.1

Table Of Contents
command.ExecuteNonQuery();
// Create new order detail
command.CommandText = "INSERT INTO orderdetail VALUES(?, ?, ?, ?, ?)";
command.ExecuteNonQuery();
// Update product quantity
command.CommandText = "UPDATE product SET quantity=? WHERE product_id=?";
command.ExecuteNonQuery();
// Commit transaction
connection.Commit();
}
catch (Exception e)
{
///
/// Log or re-throw exception
///
}
finally
{
connection.Close();
}
Performing Batch Updates
The SQLFCommand object provides AddBatch(), ExecuteBatch(), and ClearBatch() methods to explicitly
perform batch updates. The result of ExecuteBatch() is the number of rows changed by each command in a batch.
This example uses SQLFire batch operations to insert new table rows.
int numRecords = 100;
int batchSize = 10; // Limit number of statements per batch execution
string sqlfHost = "localhost";
int sqlfPort = 1527;
string connectionStr = string.Format(@"server={0}:{1}", sqlfHost, sqlfPort);
SQLFClientConnection connection = null;
try
{
connection = new SQLFClientConnection(connectionStr);
connection.Open();
SQLFCommand command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = @"INSERT INTO orders(order_id, order_date,
ship_date,
customer_id, subtotal) VALUES(?, ?, ?, ?, ?)";
// Prepare batch statement
command.Prepare();
int stCount = 0; // batch statements count
for (int i = 0; i < numRecords; i++)
{
command.Parameters[0] = <order_id>;
vFabric SQLFire User's Guide138
Developing Applications with SQLFire