Specifying Command Parameters with SQLFParameter

Use SQLFParameter and SQLFParameterCollection to define 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 specification 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 command’s Parameters collection
    SQLFParameter param1 = Command.CreateParameter();
    param1.DbType = DbType.Date;
    param1.Value = DateTime.Today;
    Command.Parameters.Add(param1);

    // Insert subtotal value add to command’s 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)
{
    ///
    /// Log or re-throw exception
    /// 
}
finally
{
    connection.Close();
}
You can also specify a range of parameters as an array of objects, as shown in this example:
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 > ?";

    // Create an object array containing parameters' value
    object[] parameters = new object[] { DateTime.Today, 999.99 };

    // Add object array as parameters (range)
    command.Parameters.AddRange(parameters);

    SQLFDataAdapter adapter = command.CreateDataAdapter();
    DataTable table = new DataTable("orders");
    adapter.Fill(table);

}
catch (Exception e)
{
    ///
    /// Log or re-throw exception
    /// 
}
finally
{
    connection.Close();
}