Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread How to convert a TEDBMemoryStream to a delphi TMemoryStream
Tue, Apr 26 2022 11:57 AMPermanent Link

George

Hi, I am quite new to this and I would appreciate it if you could help me on transforming a TEDBMemoryStream to a delphi TMemoryStream.

I need this in an external module server module for EDB server where I transfer a blob field as a parameter (which is of type TEDBMemoryStream) for further processing.

Thanks
George
Wed, Apr 27 2022 2:43 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

George


I believe they are both descended from TStream so a simple cast may work (not tried it) but you're better off doing a copy eg

 Destination.Clear;  // Clear existing data first if we're replacing it
 Destination.CopyFrom(Source, Source.Size);


Roy Lambert
Wed, Apr 27 2022 9:06 AMPermanent Link

George

Roy,

>I believe they are both descended from TStream so a simple cast may work (not tried it) but you're better off
 doing >a copy eg

>  Destination.Clear;  // Clear existing data first if we're replacing it
> Destination.CopyFrom(Source, Source.Size);

I have tried that, however I get  an error message:
 E2010 Incompatible types: 'TStream' and 'TEDBMememoryStream'

I have used the Lightweight External Module template as a basis for the module (if that helps)

Thanks

George
Thu, Apr 28 2022 12:57 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

George


I went to set up a test project but I can't find TEDBMemoryStream - which unit is it in?

Roy Lambert
Thu, Apr 28 2022 3:43 AMPermanent Link

George

Roy,

>I went to set up a test project but I can't find TEDBMemoryStream - which unit is it in?

Below is part of the code, the AsBlob is of type TEDBMemoryStream:

procedure TEDBLightweightExternalModule1.DoRoutine(const RoutineName: String);
var
 Attachment : TMemoryStream;

begin
    Attachment := TMemoryStream.Create ;
    Attachment.CopyFrom(ParamValues.FindByName('Attachment').AsBlob);

    Result := MailSender.SendEmail(......, Attachment);
end;
Thu, Apr 28 2022 4:17 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

George


Try

    Attachment.CopyFrom(TMemoryStream(ParamValues.FindByName('Attachment').AsBlob),SizeOf(TMemoryStream(ParamValues.FindByName('Attachment').AsBlob)));

and see what happens

Depending on what MailSender.SendEmail is looking for you can also try

MailSender.SendEmail(TMemoryStream(ParamValues.FindByName('Attachment').AsBlob))


Roy Lambert
Fri, Apr 29 2022 1:31 AMPermanent Link

George

Roy,

Perfect, many thanks!

George
Image