Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Blob Fields  and BlockWrite/Read

Posted on 1998-07-04
7
Medium Priority
?
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 3

Accepted Solution

by:
vladika earned 200 total points
ID: 1357099
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
ID: 1357100
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
ID: 1357101
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 3

Expert Comment

by:vladika
ID: 1357102
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
ID: 1357103
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
ID: 1357104
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
ID: 2501671
Bought this Q
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

661 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