IDataReader getInt returns wrong value

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
kolya

IDataReader getInt returns wrong value

Post by kolya » Thu 19 May 2005 14:10

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

kolya

Post by kolya » Fri 20 May 2005 10:54

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

Yuri
Posts: 140
Joined: Mon 08 Nov 2004 12:07

Post by Yuri » Fri 20 May 2005 13:34

We reproduced your problem and fixed it. This fix will be included in the next PostgreSQLDirect.NET build.
It will be available in a week.

Post Reply