Ide Indy Delphi

{
Pointer'ın üzerinde bulunduğu Record'un bir kopyasını çıkarır ve Post onayını bekler
Kullanımı : KayitCogalt(Table1);
fatihbs@hotmail.com
}
procedure TForm1.KayitCogalt(DataSeti : TDataSet);
var
StrBuffer: TStringList;
FieldStream: TMemoryStream;
I: integer;
begin
StrBuffer := TStringList.Create;
try
with DataSeti do begin
for I := 0 to FieldCount - 1 do
with Fields[I] do
if DataType in [ftString..ftDateTime] then
StrBuffer.Add(AsString)
else if DataType in [ftBytes..ftGraphic] then begin
FieldStream := TMemoryStream.Create;
if (Fields[I] is TMemoField) then
TMemoField(Fields[I]).SaveToStream(FieldStream)
else if (Fields[I] is TGraphicField) then
TGraphicField(Fields[I]).SaveToStream(FieldStream)
else if (Fields[I] is TBlobField) then
TBlobField(Fields[I]).SaveToStream(FieldStream)
else if (Fields[I] is TBytesField) then begin
FieldStream.SetSize(Fields[I].DataSize);
TBytesField(Fields[I]).GetData(FieldStream.Memory);
end
else if (Fields[I] is TVarBytesField) then begin
FieldStream.SetSize(Fields[I].DataSize);
TVarBytesField(Fields[I]).GetData(FieldStream.Memory);
end;
StrBuffer.AddObject(IntToStr(FieldStream.Size), FieldStream);
end;
Append;
for I := 0 to FieldCount - 1 do
if Fields[I].DataType in [ftString..ftDateTime] then
Fields[I].AsString := StrBuffer.Strings[I]
else if Fields[I].DataType in [ftBytes..ftGraphic] then begin
FieldStream := TMemoryStream(StrBuffer.Objects[I]);
FieldStream.Seek(0,0);
if (Fields[I] is TMemoField) then
TMemoField(Fields[I]).LoadFromStream(FieldStream)
else if (Fields[I] is TGraphicField) then
TGraphicField(Fields[I]).LoadFromStream(FieldStream)
else if (Fields[I] is TBlobField) then
TBlobField(Fields[I]).LoadFromStream(FieldStream)
else if (Fields[I] is TBytesField) then begin
TBytesField(Fields[I]).SetData(FieldStream.Memory);
end
else if (Fields[I] is TVarBytesField) then
TVarBytesField(Fields[I]).SetData(FieldStream.Memory);
StrBuffer.Objects[I] := nil;
FieldStream.Free;
end;
end;
finally
if StrBuffer <> nil then
for I := 0 to StrBuffer.Count - 1 do
if StrBuffer.Objects[I] <> nil then begin
FieldStream := TMemoryStream(StrBuffer.Objects[I]);
FieldStream.Free;
StrBuffer.Objects[I] := nil;
end;
StrBuffer.Free;
end;
end;