1.1

Table Of Contents
SQLFCommand command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = @"SELECT unit_cost, retail_price
FROM product WHERE product_id=<id>";
connection.Open();
// Create adapter and populate the DataTable object
SQLFDataAdapter adapter = command.CreateDataAdapter();
DataTable table = new DataTable("product");
adapter.Fill(table);
// Generate update command
SQLFCommandBuilder builder = new SQLFCommandBuilder(adapter);
adapter.UpdateCommand = builder.GetUpdateCommand();
// Modify product pricing
table.Rows[0]["unit_cost"] = 99.99;
table.Rows[0]["retail_price"] = 199.99;
// Update the underlying table
adapter.Update(table);
}
catch (Exception e)
{
///
/// Log or re-throw exception
///
}
finally
{
connection.Close();
}
Adding Rows to a Table
You can use SQLFCommandBuilder to update, delete, and insert rows that are stored in an SQLFDataAdapter
object.
The following example uses a SQLFDataAdapter object to store the contents of a table, and then insert new
rows.
string sqlfHost = "localhost";
int sqlfPort = 1527;
string connectionStr = string.Format(@"server={0}:{1}", sqlfHost, sqlfPort);
SQLFClientConnection connection = null;
try
{
connection = new SQLFClientConnection(connectionStr);
SQLFCommand command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = @"SELECT * FROM product";
connection.Open();
// Create adapter and populate the DataTable object
SQLFDataAdapter adapter = command.CreateDataAdapter();
DataTable table = new DataTable("product");
vFabric SQLFire User's Guide136
Developing Applications with SQLFire