1.1.1

Table Of Contents
}
}
}
catch (Exception e)
{
///
/// Log or re-throw exception
///
}
finally
{
connection.Close();
}
Specifying Command Parameters with SQLFParameter
Use SQLFParameter and SQLFParameterCollection to dene input parameters for a SQLFCommand object.
You do not need to specify the size of variable-sized data or scale and precision for numeric data. The only case
where size specication can be useful is when data must be truncated to the given size. In all other cases the
driver or server determines the data size. This applies to both input as well as output parameters. For the latter
case, the driver sets the correct size, precision, scale as appropriate.
The following example adds two SQLFParameter objects to a SQLFCommand parameter collection, and then
uses the command to create an SQLFDataAdapter.
string sqlfHost = "localhost";
int sqlfPort = 1527;
string connectionStr = string.Format(@"server={0}:{1}", sqlfHost, sqlfPort);
SQLFClientConnection connection = null;
try
{
// Initialize and open connection
connection = new SQLFClientConnection(connectionStr);
connection.Open();
SQLFCommand command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = @"SELECT * FROM orders WHERE order_date = ?
AND subtotal > ?";
// Insert order_date value and add to commands Parameters collection
SQLFParameter param1 = Command.CreateParameter();
param1.DbType = DbType.Date;
param1.Value = DateTime.Today;
Command.Parameters.Add(param1);
// Insert subtotal value add to commands Parameters collection
SQLFParameter param2 = Command.CreateParameter();
param2.DbType = DbType.Decimal;
param2.Value = 999.99;
Command.Parameters.Add(param2);
SQLFDataAdapter adapter = command.CreateDataAdapter();
DataTable table = new DataTable("orders");
adapter.Fill(table);
}
catch (Exception e)
vFabric SQLFire User's Guide138
Developing Applications with SQLFire