unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Data.DB, Data.Win.ADODB;
type
TForm1 = class(TForm)
ADOQuery1: TADOQuery;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//*************************************************
// aqui usa un componente ADOQUERY arrastrandolo
procedure TForm1.Button1Click(Sender: TObject);
var
SQLQuery: string;
begin
ADOQuery1.Active := false;
ADOQuery1.SQL.Clear;
SQLQuery:='select id from localizadores limit 10';
ADOQuery1.SQL.Add(SQLQuery);
ADOQuery1.Active := true;
if ADOQuery1.RecordCount > 0 then
begin
showmessage('ok');
end;
ADOQuery1.Active := false;
end;
//*************************************************
// aqui crea un componente ADOQUERY dinamicamente
procedure TForm1.Button2Click(Sender: TObject);
var
ADOQuery2: TADOQuery;
SQLQuery: string;
i: integer;
begin
ADOQuery2:= TADOQuery.Create(Self);
ADOQuery2.ConnectionString:='Provider=MSDASQL.1;Persist Security Info=False;Data Source=elpauGPS';
ADOQuery2.Active := false;
ADOQuery2.SQL.Clear;
SQLQuery:='select id from localizadores limit 10';
ADOQuery2.SQL.Add(SQLQuery);
ADOQuery2.Active := true;
ShowMessage(inttostr(ADOQuery2.RecordCount));
ADOQuery2.Active := false;
ADOQuery2.Destroy;
end;
end.
// fin
miércoles, 3 de junio de 2015
Suscribirse a:
Entradas (Atom)