IBM® Informix® Client Software Development Kit, Version 4.10

IfxCommandBuilder object to reconcile changes with the database

You can use the IfxCommandBuilder object to retrieve data with an SQL SELECT statement, make changes in the data set, and then reconcile those changes with the IBM® Informix® database.

The IfxCommandBuilder object facilitates easy reconciliation of changes made in your data set with the database.

For more information about the IfxCommandBuilder class, see IfxCommandBuilder class. For more information about reconciling changes in the database, see Reconcile DataSet changes with the database.

The following example shows how to use the IfxCommandBuilder object.

// Add the IBM Informix namespace
using System.Data;
using IBM.Data.Informix;
// Create a connection
IfxConnection conn=new IfxConnection("Host=berry; Service=3500; 
  Server=testserver; User ID=informix; password=ifxtest; 
  Database=testdb");
// Create a DataAdapter object 
IfxDataAdapter allDataAdapter = new IfxDataAdapter();
IfxCommand selCmd = new IfxCommand("SELECT * FROM students", conn);
allDataAdapter.SelectCommand = selCmd;
//Set up the CommandBuilder object
IfxCommandBuilder cbuild = new IfxCommandBuilder(allDataAdapter);
DataSet allDataSet = new DataSet ();
try
{
    // Open the connection
    conn.Open();
    allDataAdapter.Fill(allDataSet);
    // Change the age of a student
    DataRow chRow;
    chRow = allDataSet.Tables["Table"].Rows[5];
    chRow["age"] = 24;
    // Use IfxDataAdapter.Update() to reconcile changes with the database
    allDataAdapter.Update(allDataSet);
}
catch (Exception ex)
{
    // Use a messagebox to show any errors
    MessageBox.Show (ex.Message);
}
// Close the connection
conn.Close();


Examples exchange | Troubleshooting

To find the PDF, see Publications for the IBM Informix 12.10 family of products.
For the release notes, documentation notes, and/or machine notes, see the Release Notes page.