Skip to Content
Former Member
Apr 08, 2008 at 02:02 PM

The order of a DBDataSource - A unique key (index) can help (but...)


Hi @all!

There was often the question, if a DBDataSource could be ORDERed BY sth. Although it would be nice if somebody could disprove that: It's not possible.

Up to this my experience was that the "items" in a DBDataSource always ordered by the Code-Column. That's what my code in some situations relys on. For example if a B1-form browses by a DBDataSource then the order is not always user friendly based on a column with data the user knows.

But today I was surprised: "Suddenly" a DBDataSource-browsing form is browsing correctly by a DB-Column which the user is interested in (instead of the code-column) !

The reason for this is a unique UserKey, which I've created by SDK (UserKeysMD). The form seems to browse by the columns of the key.

But the common reason seems to be that it's standard SQL-behaviour because doing a simple query (without ORDER BY) in SQL-Management Studio also sorts the results by the unique key.

But there's one important question left:

Which key wins and why? There's also the unique index for Code on that table....