PgSqlDataTable.Load() and ORDER BY
Posted: Mon 17 Aug 2009 19:44
I'm fetching some rows from a PostgreSQL 8.3.7 database and am using ORDER BY, LIMIT and OFFSET as follows:
If I run this query manually the results are sorted and then the first ten rows are returned, which is what I would expect.
When I load the results of this query into a PgSqlDataTable using Load(PgSqlDataReader) the rows are not being loaded in the correct order.
I have tried looping through the results in the DataReader myself using Read() and the row order is still wrong, so I don't think it has anything to do with the DataTable.
Why isn't the row order being maintained by the DataReader?
Edit: I should note that I'm using the latest version of dotConnect for PostgreSQL (4.55.39).
The C# code for this is very straight forward:
"dgGrid" is a DataGrid.
Code: Select all
SELECT id, name
FROM tbl_foo
ORDER BY name
LIMIT 10 OFFSET 0;
When I load the results of this query into a PgSqlDataTable using Load(PgSqlDataReader) the rows are not being loaded in the correct order.
I have tried looping through the results in the DataReader myself using Read() and the row order is still wrong, so I don't think it has anything to do with the DataTable.
Why isn't the row order being maintained by the DataReader?
Edit: I should note that I'm using the latest version of dotConnect for PostgreSQL (4.55.39).
The C# code for this is very straight forward:
Code: Select all
using (PgSqlConnection conn = new PgSqlConnection(connString)) {
PgSqlCommand cmd = new PgSqlCommand(query, conn);
conn.Open();
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader());
}
dgGrid.DataSource = dt;
dgGrid.DataBind();