Home > Back-end >  Clientdataset scheduling problems
Clientdataset scheduling problems

Time:09-20


Have a scheduling problem, the SQL statement is a select work_years from workers

Then executes to work_years sorting, code for

Cds1. Close;
Cds1. Open;
Cds1. IndexFieldNames:='work_years';

But according to the result of is

1
10
11.
12
2
20
3

I want to show that the result is

1
2
3
10
11.
12
20

Now you can't change the SQL statement, could you tell me what to do with the code can get the result of the above order?

CodePudding user response:

After the obtained data, add index (in memory) button event to add code:
 
ClientDataSet1. AddIndex (' a ', 'work_years, [],' ', ', 0).
ClientDataSet1. IndexName:='a';

CodePudding user response:

Front is shown by the effect of string collation, followed by an integer sorting effect, if do not change the SQL table and changed the work_years field to integer type to display the integer order must be in one step into a integer types,

CodePudding user response:

Work_years field types should be a string, sorting, it is the first character sorting, the second character sorting again,
Suggestion:
1, work_years field type changed to int
2, if you don't change the field type, can modify the value of the field, a character with "0" in front of the character,

Of course, a better way is: work_years field type changed to int

  • Related