Recent

Author Topic: [Solved] How to remove SQLQuery.IndexDefs  (Read 1190 times)

Hansvb

  • Sr. Member
  • ****
  • Posts: 399
[Solved] How to remove SQLQuery.IndexDefs
« on: August 22, 2021, 11:17:19 pm »
Hi,

With the help of this:
Quote
//https://wiki.lazarus.freepascal.org/Grids_Reference_Page#Sorting_columns_or_rows_in_DBGrid_with_sort_arrows_in_column_header
I can sort a dbgrid (Dataset).

Now, when i Sort a dbgrid by clicking on a header (ROLE_NAME) and after that i want to load the data again i get the error:
Quote
SQLQuery : Index 'ASC_ROLE_NAME' not found.

I think i have to remove the Query indexes befor laoding the data again. How can that be done?

I tried:

Code: Pascal  [Select][+][-]
  1. procedure Tfrm_maintain_users.MenuItemGetUsersClick(Sender: TObject);
  2. var
  3.   i : Integer;
  4. begin
  5.       DataModuleSQlite.SQLQuery.Close;
  6.       DataModuleSQlite.SQLite3Conn.Close();
  7.  
  8.       DataModuleSQlite.SQLQuery.IndexDefs.Updated:=false;
  9.       DataModuleSQlite.SQLQuery.ClearIndexes; // Still get the error
  10.       DataModuleSQlite.SQLQuery.IndexDefs.Clear; // Still get the error
  11.  
  12.       for I:= 0 to  DataModuleSQlite.SQLQuery.IndexDefs.Count-1 do
  13.         begin
  14.           DataModuleSQlite.SQLQuery.IndexDefs.Delete(i);  // Still get the error
  15.         end;
  16.  
  17.       DataModuleSQlite.SQLQuery.IndexDefs.Update;  
« Last Edit: August 23, 2021, 11:13:12 am by Hansvb »
OS Windows 10 - Lazarus 2.0.12

Hansvb

  • Sr. Member
  • ****
  • Posts: 399
Re: How to remove SQLQuery.IndexDefs
« Reply #1 on: August 23, 2021, 11:13:01 am »
Solved by using a zeos query. Then you can sort on sortype.
OS Windows 10 - Lazarus 2.0.12

 

TinyPortal © 2005-2018