(* Collection of code snippets by Arne Vajhøj *)
(* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) *)
program DB2;

uses
  sqldb, mysql55conn, sysutils;

var
  con : TMySQL55Connection;
  tx : TSQLTransaction;
  q : TSQLQuery;

begin
  con := TMySQL55Connection.Create(nil);
  con.HostName := 'localhost';
  con.UserName:= 'root';
  con.Password:= '';
  con.DatabaseName:= 'test';
  con.Open;
  tx := TSQLTransaction.Create(nil);
  con.Transaction := tx;
  q := TSQLQuery.Create(nil);
  q.DataBase := con;
  q.SQL.Text := 'SELECT f1,f2 FROM t1 WHERE f1 > :f1';
  q.Params.ParamByName('f1').AsInteger := 2;
  q.Open;
  while not q.EOF do begin
    writeln(IntToStr(q.FieldByName('f1').AsInteger) + ' ' + q.FieldByName('f2').AsString);
    q.Next;
  end;
  q.Free;
  tx.Free;
  con.Free;
end.

