unit uSearchThread;

interface

uses
  System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param,
  FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Stan.Async,
  FireDAC.DApt, FireDAC.UI.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Phys,
  FireDAC.VCLUI.Wait, FireDAC.Phys.MySQLDef, FireDAC.Phys.MySQL, Data.DB, FireDAC.Comp.Client,
  FireDAC.Comp.DataSet,
  Vcl.ComCtrls, // Для TTreeView
  Contnrs,vcl.dialogs,
  syncobjs,vcl.Forms,vcl.Controls, uSelectionOptions,uSelectedOrChecked,uDBConnectionBPL,
  uTreeView;

type
  TSearchThread = class(TThread)
  private

  FDBTreeView:TDBTreeView;

  public

  property
  DBTreeView:TDBTreeView read FDBTreeView write FDBTreeView;

  procedure Search(name:string);

    { Private declarations }
  protected
    procedure Execute; override;
  end;

implementation

{ TSearchThread }

procedure TSearchThread.Execute;
begin
  { Place thread code here }
end;



procedure TSearchThread.Search(name: string);
var qSearch:TFDQuery;
    DBConnectionLocal:TDBConnectionBPL;

begin

DBConnectionLocal:=TDBConnectionBPL.Create(nil);
qSearch:=TFDQuery.Create(nil);
qSearch.Connection:=DBConnectionLocal.FDConnection;

qSearch.SQL.Text:='SELECT name FROM treeview_db.tree where Name like '+'''%'+name+'%''';
qSearch.Open;
//Передаем результаты в поле дерева


qSearch.Close;

FreeAndNil(DBConnectionLocal);
FreeAndNil(qSearch);

end;

end.
