Solved

Blob Fields  and BlockWrite/Read

Posted on 1998-07-04
7
306 Views
Last Modified: 2010-04-04
Hi,

I am trying to write (and read) the contents of a blob field to a file using BlockWrite.

I am trying to use the following code but it always gives me an I/O Error 87 - what ever that is, errors being documented the way they are.

    ImageStream := TBlobStream.Create(FieldByName('Image') as TBlobField,
      bmRead);
    Blockwrite(TXMessageFile, ImageStream, ImageStream.Size);

Any ideas?

Thanks

Chris

0
Comment
Question by:ChrisBerry
  • 4
  • 2
7 Comments
 
LVL 3

Accepted Solution

by:
vladika earned 50 total points
Comment Utility
Use TBlobField's method SaveToFile or SaveToStream

For example
  TBlobField(Dataset.FieldByName('Image')).SaveToFile(FileName);

You cannot use BlockWrite as you write.
You must pass Buffer to BlockWrite.
And ImageStream is not buffer.

0
 
LVL 3

Expert Comment

by:vladika
Comment Utility
If you still want use BlockWrite you can try this

var Buffer: Pointer;
      MemStream: TMemoryStream;
.............
  MemStream := TMemoryStream.Create;
  try
    TBlobField(DataSet.FieldByName('Image')).SaveToStream(MemStream);
    Buffer := MemStream.Memory;
    Blockwrite(TXMessageFile, Buffer^, MemStream.Size);
// use Buffer^ !!!! Stream is not buffer
  finally
    MemStream.Free;
  end;


0
 

Author Comment

by:ChrisBerry
Comment Utility
Thanks,

The reason I am using BlockWrite is because this bit is only part of a file I am creating.

I knew I needed a buffer but could not figure out the details.

Thanks again.

Chris

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 3

Expert Comment

by:vladika
Comment Utility
Hi, Chris

> The reason I am using BlockWrite is because this bit is only part of a file I am creating.

It is not problem. You can use TFileStream for work with
part of file as well as BlockWrite/BlockRead.

Vladika.

0
 

Author Comment

by:ChrisBerry
Comment Utility
Hi Vladika,

>It is not problem. You can use TFileStream for work with
>part of file as well as BlockWrite/BlockRead.

By this do you mean using TFileStream or using 'SaveToFile' method?

I thought 'SaveToFile' always re-wrote the file.

Chris


0
 
LVL 3

Expert Comment

by:vladika
Comment Utility
Hi Chris

You are right. I mean TFileStream of course.
I intend you may use TFileStream instead of conventional file I/O

Vladika

0
 
LVL 12

Expert Comment

by:rwilson032697
Comment Utility
Bought this Q
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now