Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.pascal.misc > Newsgroup comp.lang.pascal.delphi.databases

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 04-06-2009, 02:44 PM
Gene Lyman
Guest
 
Posts: n/a
Default TBlobSteam write problem

Hello,

I am attempting to write data to a blob field. The following shows the code
segment

try
with Fes do begin
Fes.insert;
FesNumber.AsInteger := 999;
FesOwner.Asinteger := 0;
Feed.Name := Edit3.text; // Feed is binary record, Name is string
within Feed
// Feed has been successfully
retrieved from from
// TBlobStream with a "read"
statement
DataStream :=
TBlobStream.Create(TBlobField(FeS.FieldByName('Dat a')),bmReadWrite);
DataStream.position := 0;
DataStream.Write(header,sizeof(header));
DataStream.seek(16,soFromBeginning); // offset from beginning of
blob field

case FesOwner.AsInteger of
0 : begin
DataStream.Write(feed,sizeof(feed));
end;
(* --- *)
end;
end;
finally
DataStream.free;
if Fes.state in [dsInsert,dsEdit] then
Fes.post;
end;

The Header information writes to the blob field. When the blob fields is
re-read, the "feed" information is missing. I have tried numerous
variations on this process without success. There are no error messages.
I am having the same problem in both Delphi 5 and Delphi 2009.
Thanks for any suggestions
Gene Lyman

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 04-07-2009, 09:44 PM
Jamie
Guest
 
Posts: n/a
Default Re: TBlobSteam write problem

Gene Lyman wrote:
> Hello,
>
> I am attempting to write data to a blob field. The following shows the
> code
> segment
>
> try
> with Fes do begin
> Fes.insert;
> FesNumber.AsInteger := 999;
> FesOwner.Asinteger := 0;
> Feed.Name := Edit3.text; // Feed is binary record, Name is string
> within Feed
> // Feed has been
> successfully retrieved from from
> // TBlobStream with a
> "read" statement
> DataStream :=
> TBlobStream.Create(TBlobField(FeS.FieldByName('Dat a')),bmReadWrite);
> DataStream.position := 0;
> DataStream.Write(header,sizeof(header));
> DataStream.seek(16,soFromBeginning); // offset from beginning of
> blob field
>
> case FesOwner.AsInteger of
> 0 : begin
> DataStream.Write(feed,sizeof(feed));
> end;
> (* --- *)
> end;
> end;
> finally
> DataStream.free;
> if Fes.state in [dsInsert,dsEdit] then
> Fes.post;
> end;
>
> The Header information writes to the blob field. When the blob fields
> is re-read, the "feed" information is missing. I have tried numerous
> variations on this process without success. There are no error messages.
> I am having the same problem in both Delphi 5 and Delphi 2009.
> Thanks for any suggestions
> Gene Lyman
>

It's my guess you're using the default string types in the record which
are simply pointers to a string that isn't in the record. What you're
doing is writing a 4 byte pointer value and not the actual string contents.

You need to use an array of char or Short strings in the record so
that text information is actually in the record.


http://webpages.charter.net/jamie_5"

Reply With Quote
  #3 (permalink)  
Old 04-08-2009, 11:09 PM
Gene Lyman
Guest
 
Posts: n/a
Default Re: TBlobSteam write problem


"Jamie" <jamie_ka1lpa_not_valid_after_ka1lpa_@charter.ne t> wrote in message
news:aIPCl.8849$GU6.4557@newsfe09.iad...
> Gene Lyman wrote:
>> Hello,
>>
>> I am attempting to write data to a blob field. The following shows the
>> code
>> segment
>>
>> try
>> with Fes do begin
>> Fes.insert;
>> FesNumber.AsInteger := 999;
>> FesOwner.Asinteger := 0;
>> Feed.Name := Edit3.text; // Feed is binary record, Name is string
>> within Feed
>> // Feed has been
>> successfully retrieved from from
>> // TBlobStream with a
>> "read" statement
>> DataStream :=
>> TBlobStream.Create(TBlobField(FeS.FieldByName('Dat a')),bmReadWrite);
>> DataStream.position := 0;
>> DataStream.Write(header,sizeof(header));
>> DataStream.seek(16,soFromBeginning); // offset from beginning of
>> blob field
>>
>> case FesOwner.AsInteger of
>> 0 : begin
>> DataStream.Write(feed,sizeof(feed));
>> end;
>> (* --- *)
>> end;
>> end;
>> finally
>> DataStream.free;
>> if Fes.state in [dsInsert,dsEdit] then
>> Fes.post;
>> end;
>>
>> The Header information writes to the blob field. When the blob fields is
>> re-read, the "feed" information is missing. I have tried numerous
>> variations on this process without success. There are no error
>> messages.
>> I am having the same problem in both Delphi 5 and Delphi 2009.
>> Thanks for any suggestions
>> Gene Lyman
>>

> It's my guess you're using the default string types in the record which
> are simply pointers to a string that isn't in the record. What you're
> doing is writing a 4 byte pointer value and not the actual string
> contents.
>
> You need to use an array of char or Short strings in the record so that
> text information is actually in the record.
>

Thanks Jamie,
Turns out the problem was that the "write" procedure has to be associated
with DataSet which I hadn't done.
Gene Lyman

Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 03:16 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.