IfxParameter examples

The first example creates an IfxParameter object.
//illustrates example of creating and using IfxParameter
//assume we have obtained a connection
IfxDataAdapter adpt = new IfxDataAdapter();
adpt.SelectCommand = new IfxCommand("SELECT CustomerID, Name FROM Customers 
    WHERE Country = ? AND City = ?", conn);
IfxParameter ifxp1 = new IfxParameter("Country",DbType.String);
IfxParameter ifxp2 = new IfxParameter("City",DbType.String);
//add parameter to the Parameter collection
//since our provider does not support named parameters, the order of parameters
//added to the collection is important.
Adpt.SelectCommand.Parameters.Add(ifxp1);
Adpt.SelectCommand.Parameters.Add(ifxp2);
//the above method of creating and adding a parameter can also be done in a
//single step as shown
//adpt.UpdateCommand.Parameters.Add("CustomerName",DbType.String);
//assign value to the parameter
adpt.UpdateCommand.Parameters.["CustomerName"] = "xyz";
The next example demonstrates the use of the SourceVersion and SourceColumn properties:
//The following assumptions have been made:
// 1.We have obtained a connection (conn) to our data source
//2. We have a filled a DataSet using a DataAdapter(custDA) that has the
//following SelectCommand:
// "SELECT CustomerID, CompanyName FROM Customers WHERE Country = ? AND City = 
// ?";
// 3. following is the update statement for the UpdateCommand:
// string updateSQL = "UPDATE Customers SET CustomerID = ?, CompanyName = ? " +
//                 "WHERE CustomerID = ? ";
// 4.The CustomerID column in the DataRow being used has been modified with a 
// new value.
custDA.UpdateCommand = new IfxCommand(updateSQL,conn);
//The customer id column is being used as a source for 2 parameters.
//(set CustomerID = ?, and //where CustomerID = ?)
//the last parameter to the Add command specifies the SourceColumn for the
//parameter
IfxParameter myParam1 = custDA.UpdateCommand.Parameters.Add(
    "CustomerID", IfxType.Char,5,"CustomerID");
//The following line of code is implied as default, but is provided for
//illustrative purposes
//We want to update CustomerID with the current value in the DataRow.
myParam1.SourceVersion = DataRowVersion.Current; 
//Current is the default value 
custDA.UpdateCommand.Parameters.Add("CompanyName", IfxType.VarChar);
//The last parameter to the Add command specifies the SourceColumn for the
//parameter
IfxParameter myParm2 = custDA.UpdateCommand.Parameters.Add(
    "OldCustomerID", IfxType.Char,5,"CustomerID");
//We want to use in our search filter, the original value of CustomerID in
//the DataRow
MyParm2.SourceVersion = DataRowVersion.Original;
CustDA.Update();