Link to home
Start Free TrialLog in
Avatar of DigitalNam
DigitalNamFlag for Namibia

asked on

Delphi XE10, MySQL Query

Hi all,

Can someone please help me to run this query in a thread that updates a progress bar on the mainform?

procedure TMainForm.OnComplete(ASender: Tobject; Const ReaderSerNum: WideString; Const pSample: IDispatch);
var
  recNo : Integer;
  startTime64, endTime64, frequency64: Int64;
  elapsedSeconds: single;
begin
  QueryPerformanceFrequency(frequency64);
  QueryPerformanceCounter(startTime64);
  VerifyProgress.Position := 0;
  DM.mySQLQuery.DisableControls;
  DM.mysqlQuery.SQL.Text := 'SELECT MemberFP FROM MemberTbl';
  DM.mysqlQuery.Open;
  DM.mysqlQuery.First;
  VerifyProgress.Properties.Max := DM.mySQLQuery.RecordCount;
  if DM.mysqlQuery.Eof then begin
    lblStatus.Caption := 'No Fingerprint Found in the Database';
    AdvSmoothButton7.Enabled := False;
  exit;
  end;
  recno:=0;
  while not DM.mysqlQuery.Eof do begin
    inc(recno);
    VerifyProgress.Position := recNo;
    lblStatus.Caption := 'Scanning Fingerprint Record Number: ' + inttostr(recno);
    lblStatus.Update;
    vTemplate:= DM.mysqlQuery.FieldByName('MemberFP').AsVariant;

    dptemplate.DefaultInterface.Deserialize(vTemplate);
    dpfeat.DefaultInterface.CreateFeatureSet(pSample, DataPurposeVerification);

    dpres := dpver.DefaultInterface.Verify(dpFeat.DefaultInterface.FeatureSet, dptemplate.DefaultInterface) as DPFPVerificationResult;
    if dpRes.Verified then begin
      //cxLabel4.Caption := DM.mysqlQuery.FieldByName('MemberName').AsString;
    AdvSmoothButton7.Enabled := True;
    break;
    end
    else
      lblStatus.Caption := 'Fingerprint NOT Identified';
      lblStatus.Update;
      DM.mysqlQuery.Next;
  end;
    DM.mysqlQuery.Close;
    lblStatus.Caption := 'Waiting Fingerprint to be verified...';
    lblStatus.Update;
    DM.mySQLQuery.EnableControls;
    QueryPerformanceCounter(endTime64);
    elapsedSeconds := (endTime64 - startTime64) / frequency64;
    Label4.Caption := FloatToStr(ElapsedSeconds);
end;
SOLUTION
Avatar of Thommy
Thommy
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DigitalNam

ASKER

Hi Thommy,

Thank you for the comment. I am using Unidac and to get the progress I can do but with my query on about 1000 records takes about 23 seconds. Can you perhaps help me to put my query in a thread that shows a progress on the threaded query then?
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you. Managed to shave off a few seconds on the query