Subject | AW: [IBO] What is wrong with my Blob handling? |
---|---|
Author | Queck Rainer |
Post date | 2003-06-23T08:46:58Z |
Hello Jason,
thanks for responding.
of your problem. I suggest your variable declaration look like this as well.
<
No, the "aStream" if a TTypeMemoryStream, derived from TMemoryStream. Therefore I must use the typecast.
Somehow I don't think it is the typecast, because if I modify my code using (see method : procedure TUdpToDbGui.OnTlgRcv below)
tlgStream.SaveToStream(aStream);
instead of
aStream.LoadFromStream(tlgStream);
every thing works fine, I just don't know why?
Regards
Rainer
//====
procedure TUdpToDbGui.OnTlgRcv(Sender: TObject; aGbTelegram : TGbTelegram);
var
aStream, tlgStream: TTypeMemoryStream;
aField: TIB_Column;
begin
tlgStream:=NIL;
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.Position:=0;
tlgStream.SaveToStream(aStream);
DmUdpToDb.SPC_Transaction.CommitRetaining;
finally
AStream.Free;
tlgStream.Free;
end;
//====
-----Ursprüngliche Nachricht-----
Von: IB Objects [mailto:jwharton@...]
Gesendet: Mittwoch, 18. Juni 2003 17:47
An: IBObjects@yahoogroups.com
Betreff: Re: [IBO] What is wrong with my Blob handling?
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
thanks for responding.
>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.
<
No, the "aStream" if a TTypeMemoryStream, derived from TMemoryStream. Therefore I must use the typecast.
Somehow I don't think it is the typecast, because if I modify my code using (see method : procedure TUdpToDbGui.OnTlgRcv below)
tlgStream.SaveToStream(aStream);
instead of
aStream.LoadFromStream(tlgStream);
every thing works fine, I just don't know why?
Regards
Rainer
//====
procedure TUdpToDbGui.OnTlgRcv(Sender: TObject; aGbTelegram : TGbTelegram);
var
aStream, tlgStream: TTypeMemoryStream;
aField: TIB_Column;
begin
tlgStream:=NIL;
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.Position:=0;
tlgStream.SaveToStream(aStream);
DmUdpToDb.SPC_Transaction.CommitRetaining;
finally
AStream.Free;
tlgStream.Free;
end;
//====
-----Ursprüngliche Nachricht-----
Von: IB Objects [mailto:jwharton@...]
Gesendet: Mittwoch, 18. Juni 2003 17:47
An: IBObjects@yahoogroups.com
Betreff: Re: [IBO] What is wrong with my Blob handling?
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;
Yahoo! Groups Sponsor
<http://rd.yahoo.com/M=251812.3170658.4537139.1261774/D=egroupweb/S=1705007183:HM/A=1564415/R=0/SIG=11t6t7kdo/*http://www.netflix.com/Default?mqso=60164784&partid=3170658>
<http://us.adserver.yahoo.com/l?M=251812.3170658.4537139.1261774/D=egroupmail/S=:HM/A=1564415/rand=566889153>
___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .
[Non-text portions of this message have been removed]