```
private DataRow getDataRowFromReader(IDataReader reader)
{
    DataRow row = new DataRow();
    DataTable tbl = new DataTable();
    for (int i = 0; i < reader.FieldCount; i++)
    {
        Type type = reader[i].GetType();
        if(type.Equals(Type.GetType("DBNull")) || type.Equals(Type.GetType("System.DBNull")))
            type = typeof(string);
        DataColumn col = new DataColumn(reader.GetName(i), type);
        tbl.Columns.Add(col);
    }
    row = tbl.NewRow();
    for (int i = 0; i < reader.FieldCount; i++)
    {
        Type readerType = reader[i].GetType();
        Type rowType = row[i].GetType();
        if (readerType.Equals(rowType))
            row[i] = reader.GetValue(i);
        else
            row[i] = reader.GetString(i);
    }
    return row;
}

```

I'm trying to handle DBNull in the 1st loop, but in the second I have then all rows created by NewRow() of DBNull type.

e.g. rowType ~ DBNull

Why this is happen?