Subject Re: [IBO] What is wrong with my Blob handling?
Author IB Objects
You are using a typecast. Please eliminate it and you will find the source
of your problem. I suggest your variable declaration look like this as well.

var
aStream: TStream;
tlgStream: TTypeMemoryStream;
aField : TIB_Column;
begin
...

Jason Wharton
www.ibobjects.com


----- Original Message -----
From: "Queck Rainer" <Rainer.Queck@...>
To: "IBObjects (E-Mail)" <IBObjects@yahoogroups.com>
Sent: Wednesday, June 18, 2003 4:04 AM
Subject: [IBO] What is wrong with my Blob handling?


> Hi List,
>
> I have a "little" problem, saveing a Stream into a blob field. The code of
my method is shown below.
> When ever I get to "CommitRetaining" I get a access violation :-(
> If I comment all the lines handling the stream, the method works fine.
>
> What am I doing wrong?
>
> Thanks for hints
> Rainer
>
> //===================================================
>
> TTypeMemoryStream is a descend of TMemoryStream.
>
> procedure TFrmMainUdpToDb.OnTlgRcv(Sender: TObject; aGbTelegram :
TGbTelegram);
> var
> aStream,tlgStream: TTypeMemoryStream;
> aField : TIB_Column;
> begin
> //=== TRY
> TRY
>
> aField:=DmUdpToDb.QTelegram.FieldByName('TLG_STREAM');
> DmUdpToDb.QTelegram.Append;
> TStream(aStream):=DmUdpToDb.QTelegram.CreateBlobStream(aField,bsmWrite);
> try
> with DmUdpToDb.QTelegram do
> begin
> FieldByName('TLG_ID').AsInteger:=0;
> FieldByName('TLG_NO').AsInteger:=aGbTelegram.TlgNo;
> FieldByName('TLG_SENDER_IP').AsString:=aGbTelegram.Sender.IpAddress;
> FieldByName('TLG_SENDER_PORT').AsInteger:=aGbTelegram.Sender.Port;
>
FieldByName('TLG_RECEIVER_IP').AsString:=aGbTelegram.Receiver.IpAddress;
>
FieldByName('TLG_RECEIVER_PORT').AsInteger:=aGbTelegram.Receiver.Port;
> FieldByName('TLG_DIRECTION').AsString:='I';
> FieldByName('TLG_PROCESSED').AsString:='F';
> end;
> tlgStream:=aGbTelegram.asMemoryStream;
> tlgStream.Position:=0;
> aStream.LoadFromStream(tlgStream);
> DmUdpToDb.SPC_Transaction.CommitRetaining;
> finally
> AStream.Free;
> tlgStream.Free;
> end;
> end;