Page 1 of 1

Some sample code

Posted: Mon 25 Apr 2005 21:50
by brekhof
I would like to see some sample code how to create two or more TOraQuery's run-time. The value of the 'name' property will be entered by the user.

thanks in advance,
Martin

Posted: Tue 26 Apr 2005 11:19
by Alex
The run-time creation of TOraQuery components does not differ from any other components the only thing that you must to do after creation is to setup TOraSession component (server/password/username) before open datasets that linked to it.

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  OraQuery_1, OraQuery_2 : TOraQuery;
begin
  OraQuery_1 := TOraQuery.Create(nil);
  OraQuery_2 := TOraQuery.Create(nil);

  //This steps are not necessary if you omit them then TOraQuery links
  //to the first available TOraSession object
  OraQuery_1.Session := OraSession1;
  OraQuery_2.Session := OraSession1;

  OraQuery_1.SQL.Clear;
  OraQuery_1.SQL.Text := 'Select * from emp';
  OraQuery_2.SQL.Clear;
  OraQuery_2.SQL.Text := 'Select * from dept1';
  OraQuery_1.Open;
  OraQuery_2.Open;
  //Do something with data

  OraQuery_1.Close;
  OraQuery_2.Close;
  OraQuery_1.Free;
  OraQuery_2.Free;
end;