0

I am creating a persistent index ADODataSet but not order information, my code is as follows:

ADODataSetInforArtic.IndexDefs.Clear;
case ComboBoxOrden.AsValue of
  0: begin
       with ADODataSetInforArtic.IndexDefs.AddIndexDef do
       begin
         Name := 'DenomArtic';
         Fields := 'DenomArtic';
         if ComboBoxOrden.Buttons.Image1.Id = 59 then
           Options := [ixDescending];
         ADODataSetInforArtic.IndexName := Name;
       end;
     end;

What am I doing wrong? I do it this way because it is a report I'm doing. No grid, what you have is a combo in which you choose the field that will be ordered information and another button that can select ascending or descending. I do not understand that is not working .... I use delphi xe2 Best regards

Sir Rufo
  • 18,395
  • 2
  • 39
  • 73
jmontegrosso
  • 89
  • 1
  • 11
  • What exactly isn't working for you? I have very similar code that works perfectly, and you haven't explained exactly what problem you're having with the above code. Please [edit] to make it more clear what you're asking. Thanks. – Ken White May 21 '14 at 16:29
  • You don't say how your report is generated. Some reporting engines can sort data themselves, so maybe that is what is overriding your index. I'd try temporarily adding a grid your form, so you can verify whether the index is being used or not. – MartynA May 21 '14 at 23:00
  • Just out of curiosity, what ComboBox has `.AsValue` and `Buttons`? – Ken White May 22 '14 at 22:21

1 Answers1

1

Sorry for the delay, the components I use in my projects so developed by independent programmers Spanish (JfControls), greatly facilitate the development and are more aesthetically cute. I solved my problem by using the Sort property ...

ADODataSet.Sort := 'CodigDenom DESC';

I do not understand why my previous code did not work in ADODataset. The indexDefs work wonderfully in the ClientDataSet.

Also, I use for my reports ReportBuilder

Best regards.

jmontegrosso
  • 89
  • 1
  • 11