Example #1
0
        public void ExecuteReader(Session session)
        {
            string table = this.LibraryWhereTable.Name + "." + this.Name;
            command = new iDB2Command(table, session.Connection, session.Transaction);
            command.CommandTimeout = 0;
            command.CommandType = CommandType.TableDirect;

            try
            {
                iDB2DataReader reader = command.ExecuteReader();

                    for(int i=0;i<reader.FieldCount;i++)
                    {
                        string column  = reader.GetName(i);
                        Type type = reader.GetFieldType(i);
                        Column.Create(this.AllorsSession, this, column, type);
                    }

                    while (reader.Read())
                    {
                        Row row = Row.Create(this.AllorsSession, this);
                        // Create cells for each column
                        foreach (Column col in this.Columns)
                        {
                            object value = reader.GetValue(reader.GetOrdinal(col.Name));
                            if (value != null)
                            {
                                CellFactory.Create(this.AllorsSession, row, col, value);
                            }
                        }
                    }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }