Ich bin hierfür (mal eben herunter getippt)
Delphi-Quellcode:
procedure CopyADOData( SrcCon, TarCon : TADOConnection; const TableName : string );
var
SrcData : TADOTable;
TarData : TADOQuery;
SqlStrFld : string;
SqlStrPar : string;
fld : TField;
begin
SrcData := TADOTable.Create( nil );
TarData := TADOQuery.Create( nil );
try
SrcData.Connection := SrcCon;
SrcData.TableName := TableName;
SrcData.FieldDefList.Update;
TarData.Connection := TarCon;
SqlStrFld := '';
SqlStrPar := '';
for fld in SrcData.Fields do
begin
if not( SqlStrFld = '' )
then
SqlStrFld := SqlStrFld + ', ';
SqlStrFld := SqlStrFld + fld.FieldName;
if not( SqlStrPar = '' )
then
SqlStrPar := SqlStrPar + ', ';
SqlStrPar := SqlStrPar + ':' + fld.FieldName;
end;
TarData.SQL.Text := 'INSERT INTO ' + TableName + ' ( ' + SqlStrFld + ' ) VALUES ( ' + SqlStrPar + ' )';
TarData.Prepared := True;
try
SrcData.Open;
try
while not SrcData.Eof do
begin
for fld in SrcData.FieldList do
begin
TarData.Parameters.ParamByName(fld.FieldName).Value := fld.Value;
end;
TarData.ExecSQL;
SrcData.Next;
end;
finally
SrcData.Close;
end;
finally
TarData.Prepared := False;
end;
finally
TarData.Free;
SrcData.Free;
end;
end;
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ea 0a 4c 14 0d b6 3a a4 c1 c5 b9
dc 90 9d f0 e9 de 13 da 60)