In order to make my code more generic, I want to use IDataReader instead of PgSqlDataReader:
private DataTable PopulateDataTable(IDataReader drdrDB)
{
DataTable dtblResults = this.MakeDataTable();
while(drdrDB.Read())
{
dtblResults.Rows.Add(new Object[] {drdrDB.GetInt32(0), drdrDB.GetString(1), drdrDB.GetInt32(2)});
}
return dtblResults;
}
This works fine for the getString method but getInt32 returns wrong data (negative numers or 0). If I replace the parameter type definition IDataReader by PgSqlDataReader everything works fine. What's wrong here?
Thanks,
kolya
IDataReader getInt returns wrong value
Maybe I should make myself more clear.
I wrote a generic class, which should handle both sqlserver ce and a postgres database. The method shown in my previous post is currently given a PgSqlReader as input parameter, but in the future it maybe any other implementation of the IDataReader interface. Thus, it expects an IDataReader object.
However, giving the the method a PgSqlReader object, the getInt32 method returns wrong values. This is not the case when the input parameter type is changed to PgSqlDataReader.
kolya
I wrote a generic class, which should handle both sqlserver ce and a postgres database. The method shown in my previous post is currently given a PgSqlReader as input parameter, but in the future it maybe any other implementation of the IDataReader interface. Thus, it expects an IDataReader object.
However, giving the the method a PgSqlReader object, the getInt32 method returns wrong values. This is not the case when the input parameter type is changed to PgSqlDataReader.
kolya