1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
...
begin
var
l_AuthObj : authentificationObj;
l_iCpt : Integer;
WS_Authentification_dotNET := ws_auth.GetWS_AuthSoap(false, 'adresse du web service pour l''authentification');
l_AuthObj := WS_Authentification_dotNET.RenvoiAuthentification(EditLogin.Text, EditMdp.Text);
if Assigned(l_AuthObj) and (l_AuthObj.IdConnexion = 1) then
begin
try
with FDConnection.Params do
begin
Clear;
Add('DriverID=MySQL');
Add('Server=' + l_AuthObj.IPServeurMySQL);
Add('Port=' + IntToStr(l_AuthObj.PortServeurMySQL));
Add('Database=' + l_AuthObj.nomBDD);
Add('Username=' + l_AuthObj.LoginServeurMySQL);
Add('Password=' + l_AuthObj.PasswordServeurMySQL);
Add('UseSSL=false');
if l_AuthObj.CompressionMySQL then
Add('Compress=true')
else
Add('Compress=false');
end;
Memo.Clear;
For l_iCpt := 0 to FDConnection.Params.Count - 1 do // pour afficher les infos de connexion reçus et vérifier qu'elles sont correctes.
Memo.Lines.Add(FDConnection.Params[l_iCpt]);
FDConnection.Connected := True;
LabelStatus.Caption := 'Connecté au serveur !';
except
on E : Exception do ShowMessage(E.Message);
end;
l_AuthObj.Free;
end;
procedure TFormMain.FDConnectionBeforeConnect(Sender: TObject);
begin
// emplacement du connecteur MySQL 64 bits car il n'existe pas de connecteur 32 bits avec la version 8 de MySQL
FDPhysMySQLDriverLink.VendorLib := ExtractFilePath(Application.ExeName) + 'libmysql.dll';
ShowMessage(FDPhysMySQLDriverLink.VendorLib); / pour vérifier que la lib est bien chargée
end; |