IfxCommand examples

The following example fills a data set, adds new customer information records, and then updates the database with the changes.

IfxDataAdapter idap = new IfxDataAdapter("select * from customer",con);
DataSet ds = new DataSet("customer");
idap.Fill(ds,"customer");
DataRow drow = ds.Tables["customer"].NewRow();
drow["lname"]="";
ds.Tables["customer"].Rows.Add(drow);
idap.InsertCommand = new IfxCommand();
idap.InsertCommand.CommandType = CommandType.Text;
idap.InsertCommand.CommandText = "execute procedure add_cust(?,?,?)";
idap.InsertCommand.Connection = con;
IfxParameter iparam1 = idap.InsertCommand.CreateParameter();
IfxParameter iparam2 = idap.InsertCommand.CreateParameter();
IfxParameter iparam3 = idap.InsertCommand.CreateParameter();
    iparam1.ParameterName = "fname";
    iparam1.Value = "Hoopla";
    iparam2.ParameterName = "lname";
    iparam2.Value = "MAuie";
    iparam3.ParameterName = "company";
    iparam3.Value = "Fredonia";
    idap.InsertCommand.Parameters.Add(iparam1);
    idap.InsertCommand.Parameters.Add(iparam2);
    idap.InsertCommand.Parameters.Add(iparam3);
    //Inform the command object that the update
    //results in data being returned and it must be 
    //updated against the changed row in the 
    //dataset. The source of the data is in the 
    //first returned row
    idap.InsertCommand.UpdatedRowSource= UpdateRowSource.FirstReturnedRecord;
    idap.RowUpdated += new IfxRowUpdatedEventHandler(OnRowUpdated);
    idap.InsertCommand.Connection.Open();
    idap.Update(ds,"customer");
IfxConnection conn = new IfxConnection
("Database=stores7;Server=ol_sigaram_11;UID=informix;Password=ids4data");
        IfxCommand cmd = new IfxCommand("select col1 from tbltest", conn);
        conn.Open();
        IfxDataReader myReader = cmd.ExecuteReader();
        while (myReader.Read())
        {  
            Console.WriteLine("{0}", myReader.GetString(0));
        }
        myReader.Close();
        myReader.Dispose();
        cmd.Dispose();
        conn.Close();
        conn.Dispose();