IfxDataReader example
The following example demonstrates how to use the properties
and methods of the IfxDataReader class.
// IfxConnection - con
string sql = "select stock_num,manu_code,description from stock";
con.Open();
IfxCommand selectCommand = new IfxCommand(sql,con);
IfxDataReader reader = selectCommand.ExecuteReader(CommandBehavior.Default);
//schema for Dataset can be created by GetSchemaTable()
DataTable schema = reader.GetSchemaTable();
//read to use reader properties.
reader.Read();
Console.WriteLine("Depth is ");
Console.WriteLine(reader.Depth);
Console.WriteLine("Number of Columns are");
Console.WriteLine(reader.FieldCount);
Console.WriteLine("Number of Rows Changed");
Console.WriteLine(reader.RecordsAffected);
Console.WriteLine("Is Data Reader Closed ?");
Console.WriteLine(reader.IsClosed);
do
{
while (reader.Read())
{
Int32 num = reader.GetInt32(0);
Console.WriteLine(num );
String string1 = reader.GetString(1);
Console.WriteLine(string1);
String string2 = reader.GetString(2);
Console.WriteLine(string2);
}
} while (reader.NextResult());
reader.Close();
reader.Dispose(); //To prevent high memory usage, Dispose() method is called.
//Close Connection