June 9th, 2011, 07:10 AM
OdbcDataReader returns no rows after executing query even though there are some in DB
I'm getting pretty desperate with my database access logic. I have an ASP.NET application connecting to a PostgreSQL db using ODBC (on Windows 7, 64bit). I have VS 2008 and .NET 3.5 installed on the machine.
I'm trying to get data like so:
this.SetCommandProperties(statement, parameters, commandTimeout);
OdbcDataReader resultReader = odbcCommand.ExecuteReader();
but after the above code has executed, resultReader.HasRows returns false and resultReader.Read() also returns false.
I'm sure the query should have results because:
1) I enabled query tracing in PostgreSQL and the query with correctly assigned parameters showed up in the PostgreSQL log. Then I ran the query using pgAdmin and it returned the rows I needed
2) I also inspected the application using Wireshark - to the application's query there came a response with the needed rows.
So it looks like my ODBC driver is broken or misconfigured or something... Any ideas? Please help!
June 9th, 2011, 08:41 AM
Re: OdbcDataReader returns no rows after executing query even though there are some i
Problem solved :-) I was using an incorrect PostgreSQL ODBC driver. Instead of using a 32-bit driver for 8.3 I was using a 64-bit driver for 9.0.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!