Search code examples
mysqldelphifiremonkey

how to show more than one result on query


I have a procedure on MySQL that returns two results and I need to show this on Delphi but I didn't find how to pass for each result.

enter image description here

Here is how appear on DBForge when I execute, I want this on delphi too, show Query1 and Query2 in a TTabControl.

How to go through this queries and get the name of the query like: Query1,Query2?


Solution

  • I solve the problem with the command

     var 
      tab: TTabItem;
      stringGrid: TStringGrid;
    
    repeat
    
        tab:= TTabItem.Create(nil);
        tab.Parent:= tabcontrol1;
        tab.Text:= query.Fields.Fields[0].FieldName; //the table name
    
        stringGrid:= TStringGrid.Create(Self);
        stringGrid.Parent:= tab;
        stringGrid.Align:= TAlignLayout.Client;
    
    
        for I := 1  to query.FieldCount-1 do
        begin
          
          stringGrid.AddObject(TStringColumn.Create(stringGrid));
          stringGrid.Columns[i-1].Header:= query.Fields.Fields[i].FieldName;
    
          query.First;
    
          for j := 0 to query.RecordCount-1 do
          begin
           stringGrid.cells[i-1, j]:= query.Fields.Fields[i].value;
           query.Next;
          end;
        end;
    
        stringGrid.RowCount:= j;
    
    until not query.openNext;