Specifying Command Parameters with GFXDParameter

Use GFXDParameter and GFXDParameterCollection to define input parameters for a GFXDCommand 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 GFXDParameter objects to a GFXDCommand parameter collection, and then uses the command to create an GFXDDataAdapter.
string gfxdHost = "localhost";
int gfxdPort = 1527;
string connectionStr = string.Format(@"server={0}:{1}", gfxdHost, gfxdPort);

GFXDClientConnection connection = null;

try
{
    // Initialize and open connection
    connection = new GFXDClientConnection(connectionStr);
    connection.Open();

    GFXDCommand 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
    GFXDParameter param1 = Command.CreateParameter();
    param1.DbType = DbType.Date;
    param1.Value = DateTime.Today;
    Command.Parameters.Add(param1);

    // Insert subtotal value add to command’s Parameters collection
    GFXDParameter param2 = Command.CreateParameter();
    param2.DbType = DbType.Decimal;
    param2.Value = 999.99;
    Command.Parameters.Add(param2);

    GFXDDataAdapter 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 gfxdHost = "localhost";
int gfxdPort = 1527;
string connectionStr = string.Format(@"server={0}:{1}", gfxdHost, gfxdPort);

GFXDClientConnection connection = null;

try
{
    // Initialize and open connection
    connection = new GFXDClientConnection(connectionStr);
    connection.Open();

    GFXDCommand 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);

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

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