|
|||
|
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 |
|
|
||||
|
||||
|
|
|
|||
|
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" |
|
|||
|
"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 |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|