实际上还是要用控件,自己做太难了吧。只不过可以动态创建控件和连接字符串。
var
ADOConnection1:TADOConnection;
ADOQuery1:TADOQuery;
procedure AProc;
begin
ADOConnection1:=TADOConnection.Create(nil);
with ADOConnection1 do
begin
ConnectionString:='.....';
Provider:='....';
// 或
Properties.Item['Data Source'].Value:='...';
Properties.Item['Password'].Value:='...';
......
end;
ADOQuery1:=TADOQuery.Create(nil);
with ADOQuery1 do
begin
Connection:=ADOConnection1;
SQL.Text:='...';
Open;
end;
ADOQuery1.Free;
ADOConnection1.Free;
end;