Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread TEDBBlobStream to TMemoryStream question
Sat, Aug 22 2015 5:30 AMPermanent Link

Carl

Hi everybody

I am taking an TRichEditor (memory)stream AValue and trying to write it to a ClientDataSet->EDBQuery Blob field.

This is the code snippet with the two methods I am trying:

        try
         try

         { Method 1: ClientDataSetApplicationVersionsAboutNotes: TBlobField; }
//          L_BlobStream := TEDBBlobStream.Create
//            (ClientDataSetApplicationVersionsAboutNotes, bmWrite);
         { Method 2: FieldByName }
           L_BlobStream := TEDBBlobStream.Create
             (TBlobField(ClientDataSetApplicationVersions.FieldByName
             ('AboutNotes')), bmWrite);

           AValue.SaveToStream(L_BlobStream);
         except
           raise;
         end;
       finally
         L_BlobStream.Free;
       end;

In both cases, the TEDBBlobStream.Create fails with an "Invalid class typecast" from the System unit. There is an Edit and Post before and after this code.

I studied the docs and forum for this, I think I am doing the correct steps, but I guess not, or there is a coding mistake.

Any ideas? Thanks.
Sun, Aug 23 2015 2:57 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Carl


What is L_BlobStream defined as?


Roy Lambert
Mon, Aug 24 2015 3:05 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Carl,

I<< n both cases, the TEDBBlobStream.Create fails with an "Invalid class typecast" from the System unit. There is an Edit and Post before and after this code. >>

Are you sure that the TField that you're casting to a TBlobField is actually a TBlobField (or descendant) ?

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Aug 25 2015 2:21 AMPermanent Link

Carl

Tim Young [Elevate Software] wrote:

Carl,

I<< n both cases, the TEDBBlobStream.Create fails with an "Invalid class typecast" from the System unit. There is an Edit and Post before and after this code. >>

Are you sure that the TField that you're casting to a TBlobField is actually a TBlobField (or descendant) ?

Tim Young
Elevate Software
www.elevatesoft.com

var
 L_BlobStream: TEDBBlobStream; (L_ is local var)

For Method 1:
ClientDataSetApplicationVersionsAboutNotes: TBlobField comes from the field editor for the clientdataset. Unless I am missing something, it looks like a TBlobField.
For Method 2:
The ...FieldbyName is cast as TBlobField.

Both methods produce the same error.

Also, I solved the problem by using the traditional ClientDataSetApplicationVersionsAboutNotes.SaveToStream(Result), where Result is a TMemoryStream in a property Get function. I used LoadFromStream(L_ms) in the Set procedure. L_ms is a TMemoryStream. This works great. These are TPicture images (jpg, bmp,...). Shows in Manager preview, no problem.

So I am not sure this is a real issue. I was just trying to follow the docs to properly read/write blobs.

Also, maybe this for the new Extremely Ignorant forum; when I reply to a forum thread, I am not adding an separate item, but keying my response into the last item posted. Any guidance would be helpful.

Thanks!
Tue, Aug 25 2015 2:34 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Carl,

<< var
 L_BlobStream: TEDBBlobStream; (L_ is local var)

For Method 1:
ClientDataSetApplicationVersionsAboutNotes: TBlobField comes from the field editor for the clientdataset. Unless I am missing something, it looks like a TBlobField.
For Method 2:
The ...FieldbyName is cast as TBlobField.

Both methods produce the same error. >>

Okay, I missed the obvious - you're trying to save a *TClientDataSet*'s TBlobField using a *TEDB*BlobStream.  You can't mix the two, since one is from Embarcadero and the other is ours.  You can only use TEDBBlobStreams with TEDBDataSet-descendants, such as the TEDBTable, TEDBQuery, etc.

<< Also, maybe this for the new Extremely Ignorant forum; when I reply to a forum thread, I am not adding an separate item, but keying my response into the last item posted. Any guidance would be helpful. >>

Are you referring to the Reply links next to each message ?  If so, then always try to reply to the message that you wish to reply to.  You don't see the linkages here because of the display format, but it *does* show in a newsreader, and it will show if we switch to a nested display format in the future.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Aug 25 2015 3:15 PMPermanent Link

Carl

Tim Young [Elevate Software] wrote:

Carl,

<< var
 L_BlobStream: TEDBBlobStream; (L_ is local var)

For Method 1:
ClientDataSetApplicationVersionsAboutNotes: TBlobField comes from the field editor for the clientdataset. Unless I am missing something, it looks like a TBlobField.
For Method 2:
The ...FieldbyName is cast as TBlobField.

Both methods produce the same error. >>

Okay, I missed the obvious - you're trying to save a *TClientDataSet*'s TBlobField using a *TEDB*BlobStream.  You can't mix the two, since one is from Embarcadero and the other is ours.  You can only use TEDBBlobStreams with TEDBDataSet-descendants, such as the TEDBTable, TEDBQuery, etc.

<< Also, maybe this for the new Extremely Ignorant forum; when I reply to a forum thread, I am not adding an separate item, but keying my response into the last item posted. Any guidance would be helpful. >>

Are you referring to the Reply links next to each message ?  If so, then always try to reply to the message that you wish to reply to.  You don't see the linkages here because of the display format, but it *does* show in a newsreader, and it will show if we switch to a nested display format in the future.

Tim Young
Elevate Software
www.elevatesoft.com

Great, that is the answer!

As far as the reply goes, when I click on a reply link it brings in the entire post to which I am replying... I mean do I delete that stuff, then key my reply, does it matter? Just trying to follow protocol.

Thanks for your help.
Mon, Aug 31 2015 11:17 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Carl,

<< As far as the reply goes, when I click on a reply link it brings in the entire post to which I am replying... I mean do I delete that stuff, then key my reply, does it matter? Just trying to follow protocol. >>

The existing text is just included as a convenience, but yes, you should try to weed out anything that you aren't directly replying to, in order to make the replies more readable.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Image