You are not logged in.
Hi AB
I try to assign a TMemoryStream with size = 272421 to a TSQLRawBlob
First i tried this easy method - which raises an exception converting the Bytes to JSON (at approx. 40 Bytes before the end..):
LStream : TMemoryStream;
..
rec.BinaryData := TByteDynArray(LStream.Memory);
..
Client.Update(rec, 'Binarydata') <-- Exception $C0000005 in BytesToBase64JSONString Here something goes wrong
Now i experimented a little and found a working solution. But i don't really know if this is the optimum cause it also raises an exception in a special case
LStream : TMemoryStream;
aDaten : Pointer;
..
try
rec := TBinaryRecord.Create;
...
try
GetMem(aDaten, LZipStream.Size);
LStream.Position := 0;
LStream.ReadBuffer(aDaten^, LStream.Size);
rec.Binaerdaten := TByteDynArray(aDaten);
Client.Update(rec, 'BinaryData');
finally
// FreeMem(aDaten); // commented out cause of exception in rec.Free
end;
finally
rec.Free; <-- Raises Exception if i use FreeMem(aDaten)
end;
Now my question: What is the prefered way to assign a TMemoryStream Content to a TSQLRawBlob using CrossPlatform Client ?
Last edited by itSDS (2015-06-12 10:00:26)
Rad Studio 12.3 Athens / 13.0 Ganymede
Offline
You are mixing TByteDynArray and pointers variables there...
Those two types are perfectly incompatible.
Writing TByteDynArray(aDaten) and TByteDynArray(LStream.Memory) do compile, but would raise GPF at runtime.
A TByteDynArray is not just a memory pointer, it is a special kind of content, with a length and reference count encoded before the data.
Offline
Hi AB - i was a little bit stupid - thanks for your hint
Rad Studio 12.3 Athens / 13.0 Ganymede
Offline