Retrieve multiple rows

You can use an IfxDataReader object for simple access to data when you do not have to write and do not have to move backward.

The following example connects to the stores_demo database and uses an IfxDataReader object to retrieve all of the first names from the customer table. For more information about the IfxDataReader class, see IfxDataReader class.

try 
{
    // Open a connection
    IfxConnection conn = 
        new IfxConnection(
        "Host=myhost;Service=1541;Server=myifxserver;Database=stores_demo;"
        + "User ID=mylogin;password=mypassword"
        );
    conn.Open();

// Create an SQL command
IfxCommand cmd = new IfxCommand(
              "SELECT fname FROM customer", 
              conn );
IfxDataReader dr = cmd.ExecuteReader();
// Write the data to the console
while (dr.Read())
{
    Console.WriteLine(dr["fname"].ToString());
}
Console.ReadLine(); // Wait for a Return
dr.Close();

// Close the connection
conn.Close();
}
catch(IfxException e) 
{
    Console.WriteLine(e.ToString());
    Console.ReadLine(); // Wait for a Return
}