Hi + tx for any info.
I want to copy data from an MSSQL database to an SQLite database.
This is how I create the object managers:
function TmodelMain.CreateMSSQLManager: TObjectManager;
begin
Result := TObjectManager.Create(conMSSQL.CreateConnection, TMappingExplorer.Get('Source'));
end;
function TmodelMain.CreateSQLiteManager: TObjectManager;
begin
Result := TObjectManager.Create(conSQLite.CreateConnection, TMappingExplorer.Get('Target'));
end;
This is how I copy the data:
for LebensmittelMSSQL in modelMain.GetLMCursor(nTotal) do begin
modelMain.AddLebensmittelToSQLite(LebensmittelMSSQL);
end;
Finally, the saving:
procedure TmodelMain.AddLebensmittelToSQLite(Lebensmittel: entityLebensmittel.TTBLLebensmittel);
begin
mgrSQLite.Save(Lebensmittel);
end;
However, on destroying things,
procedure TmodelMain.DataModuleDestroy(Sender: TObject);
begin
FreeAndNil(mgrMSSQL);
FreeAndNil(mgrSQLite);
end;
freeing the mgrSQLite fails with an invalid pointer.
If I comment the line mgrSQLite.Save, freeing the managers succeeds. I think,the entity belongs now to both managers and this is why the second free fails, as it also tries to free the entity.
What am I doing wrong here?
Thanks for support!