1.1.1

Table Of Contents
command.CommandText = "SELECT * FROM product WHERE product_id=?";
SQLFDataAdapter adapter = command.CreateDataAdapter();
DataTable table = new DataTable("product");
adapter.Fill(table);
// Create new order
command.CommandText = "INSERT INTO orders VALUES(?, ?, ?, ?, ?)";
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
vFabric SQLFire User's Guide142
Developing Applications with SQLFire