Board index » delphi » Blob => Invalid class typecast?

Blob => Invalid class typecast?

Hi guys,

I'm experiencing some trouble with blobfields.

I try to read/write a WAV-File to an interbase blobfield, but i get the
following error:
Invalid

var
  FileStream: TFileStream;
  BlobStream: TBlobStream;
begin
  BlobStream := TBlobStream.Create(DM.IBMessagesTblMessageBlob, bmRead);
  if BlobStream.Size = 0 then begin
    BlobStream.Free;
    Exit;
  end;
  FileStream := TFileStream.Create('Temp.wav', fmCreate or fmOpenWrite);
  FileStream.CopyFrom(BlobStream, BlobStream.Size);
  FileStream.Free; BlobStream.Free;
end;

DM is the name of my Datamodule
IBMessageTblMessageBlob is a TBlobField of Subtype 0

Anybody having a clue what i'm doing wrong (or forgot to do)?

Kind Regards,
Olivier Peter.

 

Re:Blob => Invalid class typecast?


Try:

var
  B, F: TStream;
begin
  B := DM.IBMessagesTbl.CreateBlobStream(DM.IBMessagesTblMessageBlob,
bmRead);
  try
    if B.Size > 0 then
    begin
      F := TFileStream.Create('temp.wav', fmCreate);
      try
        F.CopyFrom(B, 0);
      finally
        F.Free;
      end;
    end;
  finally
    B.Free;
  end;
end;

Quote
"Olivier Peter" <pe...@kryptonline.com> wrote in message

news:tRWx7.103613$6x5.22256293@afrodite.telenet-ops.be...
Quote
> Hi guys,

> I'm experiencing some trouble with blobfields.

> I try to read/write a WAV-File to an interbase blobfield, but i get the
> following error:
> Invalid

> var
>   FileStream: TFileStream;
>   BlobStream: TBlobStream;
> begin
>   BlobStream := TBlobStream.Create(DM.IBMessagesTblMessageBlob, bmRead);
>   if BlobStream.Size = 0 then begin
>     BlobStream.Free;
>     Exit;
>   end;
>   FileStream := TFileStream.Create('Temp.wav', fmCreate or fmOpenWrite);
>   FileStream.CopyFrom(BlobStream, BlobStream.Size);
>   FileStream.Free; BlobStream.Free;
> end;

> DM is the name of my Datamodule
> IBMessageTblMessageBlob is a TBlobField of Subtype 0

> Anybody having a clue what i'm doing wrong (or forgot to do)?

> Kind Regards,
> Olivier Peter.

Re:Blob => Invalid class typecast?


?a marche!

Thanks,

M.H. Avegaart <avega...@NOSPAMmccomm.nl> schreef in berichtnieuws
9qgteb$1no...@scavenger.euro.net...

Quote
> Try:

> var
>   B, F: TStream;
> begin
>   B := DM.IBMessagesTbl.CreateBlobStream(DM.IBMessagesTblMessageBlob,
> bmRead);
>   try
>     if B.Size > 0 then
>     begin
>       F := TFileStream.Create('temp.wav', fmCreate);
>       try
>         F.CopyFrom(B, 0);
>       finally
>         F.Free;
>       end;
>     end;
>   finally
>     B.Free;
>   end;
> end;

> "Olivier Peter" <pe...@kryptonline.com> wrote in message
> news:tRWx7.103613$6x5.22256293@afrodite.telenet-ops.be...
> > Hi guys,

> > I'm experiencing some trouble with blobfields.

> > I try to read/write a WAV-File to an interbase blobfield, but i get the
> > following error:
> > Invalid

> > var
> >   FileStream: TFileStream;
> >   BlobStream: TBlobStream;
> > begin
> >   BlobStream := TBlobStream.Create(DM.IBMessagesTblMessageBlob, bmRead);
> >   if BlobStream.Size = 0 then begin
> >     BlobStream.Free;
> >     Exit;
> >   end;
> >   FileStream := TFileStream.Create('Temp.wav', fmCreate or fmOpenWrite);
> >   FileStream.CopyFrom(BlobStream, BlobStream.Size);
> >   FileStream.Free; BlobStream.Free;
> > end;

> > DM is the name of my Datamodule
> > IBMessageTblMessageBlob is a TBlobField of Subtype 0

> > Anybody having a clue what i'm doing wrong (or forgot to do)?

> > Kind Regards,
> > Olivier Peter.

Other Threads