Subject | What is wrong with my Blob handling? |
---|---|
Author | Queck Rainer |
Post date | 2003-06-18T11:04:29Z |
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;
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;