Urgent: Different order of records on MySQL and DBGrid

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for MySQL in Delphi and C++Builder
Post Reply
mpcsmits
Posts: 3
Joined: Thu 07 Jun 2007 15:37

Urgent: Different order of records on MySQL and DBGrid

Post by mpcsmits » Thu 21 Feb 2008 13:04

I am using FetchOnDemand true and am performing the following query:

Code: Select all

select tatanaam from tatranp where tatanaam like '%m%' order by tatanaam
In MySQL I am getting the following
  • ' name
    1 name
    2 name
    and so on
So the string with the quote is the first record. In the DBGrid the record with the starting quote is showing as last. Used with FetchOnDemand this leeds to unwanted results.

The table is defined as latin1/latin1_general_ci.

I haven't specified any index or anything else on the SimpleDataSet that might cause reordering of the records. I tried adding tatanaam as index, but that leads to the same result.

I would expect the grid to show the records in the order they were retrieved by the MySQL server. Instead some kind of sorting is applied.

What can be the problem ?

mpcsmits
Posts: 3
Joined: Thu 07 Jun 2007 15:37

Post by mpcsmits » Fri 22 Feb 2008 09:36

Took me some time, but it got resolved. Problem is the TSimpleDataSet.

Don't ask me why the sorting gets adjusted. Based on simple sorting the quote should come before numbers (or am I missing something here).

Anyhow, I had to replace the SimpleDataSet by the 3 other components: SQLQuery, DataSetProvider and ClientDataSet.

DataSetProvider has a Options property, one of the options being poRetainServerOrder. Setting that one keeps the right order and gets rid of the problem.

Unfortunately the Options property of the internal DataSetProvider of the SimpleDataSet is not exposed hence the replacement.

So it's not a driver issue.

Post Reply