IndexFieldNames (multiuse query) lazarus / 16-Databases ---------------------------------------------------------------------- exdatis · 2012-07-06 06:38 Hi! I have SQLQuery component  for simple queries which I use many times with different SQL, e.g.   DbModule.SQLAny.Close;   DbModule.SQLAny.SQL.Clear;   DbModule.SQLAny.SQL.Text:= SOME_SQL; //+ open The problem occurs if I use(db_grid on TitleClick):     if not DbModule.SQLAny.IsEmpty then       DbModule.SQLAny.IndexFieldNames:= Column.FieldName; After close/open new form(and use SQLAny), I've got error because IndexFiled exist. I tried: DbModule.SQLAny.IndexFieldNames:= ''; without success.  How to clear IndexFieldNames? Thanks. C.T.2.5 XUbuntu12.4(32), Firebird2.5 ---------------------------------------------------------------------- exdatis · 2012-07-07 10:34 Well, I suppose, I'll have to find an alternative solution. Thank you anyway. Regards. ---------------------------------------------------------------------- TheBlackSheep · 2012-07-07 11:44 Hi exdatis I tend to build the SQL and us the "order by" and the field name of the titlebutton - you have more control and you don't have to worry whether there is an index or not (you can sort by any field - the relevant sql engine should use the relevant index if one exists for the query). You will need to add the "asc" or "desc" depending on which was title button was clicked before - sort by asc if it's a different field than last time and only do "desc" if it was the same field and "asc" was used in the previous query. TheBlackSheep ---------------------------------------------------------------------- exdatis · 2012-07-07 11:50 Thank you very much TheBlackSheep. Good idea. Regards!