Search code examples
c#.netsortingms-accessoledb

MS Access sort (comparing string data)


I have a .NET application that use MS Access as a database. The application worked OK and still works on my PC. But after reinstalling the Windows on client PC, the Application started to work in a very strange way.

In the database the data is in Cyrillic (Macedonian). The problem is that the database does not sort strings correctly.

For example, if i run the following query:

SELECT * FROM exampletbl ORDER BY title

The expected results should be:

id  title
1   Александар
2   Бранко
3   Влатко
4   Гоце
5   Гвозден
6   Дарко
7   Ѓоре
8   Ѓурѓа

...

And currently the access it sorts in this way:

id  title
1   Александар
2   Бранко
3   Влатко
4   Гоце
5   Ѓоре
6   Гвозден
7   Ѓурѓа
8   Дарко

...

My guess is that region settings or OLE DB driver are not configured propertly on a client PC and that access is sorting the data as Latin letters.

p.s. The client windows version is Windows 7 x86


Solution

  • To Change the sort order (on a new database) go to File > Options > General > Creating Databases> New Database Sort Order.

    enter image description here

    This will give you

    enter image description here

    To have that change take effect in the current database perform a Compact and Repair. That will create a new database in the background (Thanks Gord Thompson for the suggestion)