DeWeb - 主动连接数据库FDConnection

procedure TForm1.Button1Click(Sender: TObject);
var
oForm : TForm;
oFDConn : TFDConnection;
iItem : Integer;
begin
oForm := Screen.Forms[0];
for iItem := 0 to oForm.ComponentCount - 1 do begin
if oForm.Components[iItem].ClassName = 'TFDConnection' then begin
oFDConn := TFDConnection(oForm.Components[iItem]);
if not oFDConn.Connected then begin
oFDConn.Open;
end;
end;
end;
//dwShowMessage('success',self);
end;

posted @ 2025-08-27 16:31  碧树西风Delphi  阅读(20)  评论(0)    收藏  举报