Procedure Thread_CopyStoClient.CopyStoClient(DBServerName,DBClientName, User, Passwort:String);
var
N_Str,
V_Str,
H_Str,
Query_Str,
LocalDatum :String;
FDConnectionLocal: TFDConnection;
FDConnectionServer: TFDConnection;
FDBatchMove: TFDBatchMove;
FDBatchMoveSQLReader: TFDBatchMoveSQLReader;
FDBatchMoveSQLWriter: TFDBatchMoveSQLWriter;
begin
N_Str :='';
V_Str := '';
try
FDConnectionServer := TFDConnection.Create(nil);
with FDConnectionServer.Params do
begin
Clear;
case U_Declare.DBServerTyp of
1 : begin
DriverID := 'Ora';
Database := '(DESCRIPTION=(ADDRESS=(PROTOCOL=
TCP)(HOST='+U_Declare.ServerNameIP+')(PORT=1521))(CONNECT_DATA=(SERVICE_NAME='
+U_Declare.DBServerName+')))';
end;
2 : begin
DriverID := '
MySQL';
Add('DriverID=
MySQL');
Add('Server='+U_Declare.ServerNameIP);
Add('Port=3306');
Add('Database='+U_Declare.DBServerName); {}
end;
end;
UserName := U_Declare.Tankdaten.Local_Server_user_Name;
Password := U_Declare.Tankdaten.Local_Server_Passwort;
end;
FDConnectionServer.Open;
FDConnectionLocal := TFDConnection.Create(nil);
With FDConnectionLocal.Params do
begin
Clear;
case U_Declare.DBClientTyp of
1 : begin // Oracle
DriverID := 'Ora';
Database := '(DESCRIPTION=(ADDRESS=(PROTOCOL=
TCP)(HOST='+U_Declare.ClientNameIP+')(PORT=1521))(CONNECT_DATA=(SERVICE_NAME='
+U_Declare.DBClientName+')))';
end;
2 : begin //
MySQL
DriverID := '
MySQL';
Add('DriverID=
MySQL');
Add('Server='+U_Declare.ClientNameIP);
Add('Port=3306');
Add('Database='+U_Declare.DBClientName); {}
end;
end;
UserName := U_Declare.Tankdaten.Local_Server_user_Name;
Password := U_Declare.Tankdaten.Local_Server_Passwort;
end;
FDConnectionLocal.Open;
FDBatchMove := TFDBatchMove.Create(nil);
FDBatchMoveSQLReader := TFDBatchMoveSQLReader.Create(FDBatchMove);
FDBatchMoveSQLWriter := TFDBatchMoveSQLWriter.Create(FDBatchMove);
FDBatchMove.Reader := FDBatchMoveSQLReader;
FDBatchMove.Writer := FDBatchMoveSQLWriter;
FDBatchMove.Mode := dmAppendUpdate;
FDBatchMoveSQLReader.Connection := FDConnectionServer;
FDBatchMoveSQLWriter.Connection := FDConnectionLocal;
FDBatchMoveSQLReader.TableName :='Mitarbeiter';
FDBatchMoveSQLWriter.TableName :='Mitarbeiter';
FDBatchMove.Execute; // <-- Hier kommt der Fehler
if (FDBatchMoveSQLWriter<> nil) then begin
FDBatchMoveSQLWriter.free;
FDBatchMoveSQLWriter :=nil;
end;
if (FDBatchMoveSQLReader<> nil) then begin
FDBatchMoveSQLReader.free;
FDBatchMoveSQLReader :=nil;
end;
if (FDBatchMove<> nil) then begin
FDBatchMove.free;
FDBatchMove :=nil;
end;
if (FDBatchMoveSQLWriter<> nil) then begin
FDBatchMoveSQLWriter.free;
FDBatchMoveSQLWriter :=nil;
end;
if (FDBatchMoveSQLReader<> nil) then begin
FDBatchMoveSQLReader.free;
FDBatchMoveSQLReader :=nil;
end;
if (FDBatchMove<> nil) then begin
FDBatchMove.free;
FDBatchMove :=nil;
end;
if (FDConnectionLocal<> nil) then begin
FDConnectionLocal.close;
FDConnectionLocal.free;
FDConnectionLocal :=nil;
end;
if (FDConnectionServer<> nil) then begin
FDConnectionServer.close;
FDConnectionServer.free;
FDConnectionServer :=nil;
end;
DM_DBModul.TimerStammdaten.Enabled := True;
except
on E:
Exception do begin
U_Declare.Logdatent_Schreiben('Fehler in CopyStoClient DBServerName: '+DBServerName+' DBClientName: '+DBClientName+' Fehler: '+E.Message);
U_Declare.Logdatent_Schreiben('Fehler in CopyStoClient Query_Str: '+Query_Str);
U_Declare.Logdatent_Schreiben('Fehler in CopyStoClient N_Str+V_Str: '+N_Str+V_Str);
if (FDBatchMoveSQLWriter<> nil) then begin
FDBatchMoveSQLWriter.free;
FDBatchMoveSQLWriter :=nil;
end;
if (FDBatchMoveSQLReader<> nil) then begin
FDBatchMoveSQLReader.free;
FDBatchMoveSQLReader :=nil;
end;
if (FDBatchMove<> nil) then begin
FDBatchMove.free;
FDBatchMove :=nil;
end;
if (FDConnectionLocal<> nil) then begin
FDConnectionLocal.close;
FDConnectionLocal.free;
FDConnectionLocal :=nil;
end;
if (FDConnectionServer<> nil) then begin
FDConnectionServer.close;
FDConnectionServer.free;
FDConnectionServer :=nil;
end;
end;
end;
end;