with Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from template');
SQL.Add('where id="'+Edit1.Text+'"');
open; if Query1.RecordCount>0 then
begin
for i:=0 to Query1.RecordCount-1 do
begin
RBn[i]:=TRadioBuoon.Create(self);//RBn:array of TRadioButton
RBn[i].Parent:= Panel1;
RBn [i].Width:=20;
RBn[i].Height:=3;
RBn[i].Left:=(RBn[i].Height)*(i-1);
RBn[i].Top:=(RBn[i].Width)*(i-1);
RBn[i].Caption:=FieldByName('name').AsString;
next;
end;
end;
end;
begin
Close;
SQL.Clear;
SQL.Add('select * from template');
SQL.Add('where id="'+Edit1.Text+'"');
open; if Query1.RecordCount>0 then
begin
for i:=0 to Query1.RecordCount-1 do
begin
RBn[i]:=TRadioBuoon.Create(self);//RBn:array of TRadioButton
RBn[i].Parent:= Panel1;
RBn [i].Width:=20;
RBn[i].Height:=3;
RBn[i].Left:=(RBn[i].Height)*(i-1);
RBn[i].Top:=(RBn[i].Width)*(i-1);
RBn[i].Caption:=FieldByName('name').AsString;
next;
end;
end;
end;
数组必须声明完大小再使用
SQL.Add(' where id='''+Edit1.Text+''''); //注意where之前要有空格