Solved

Blob Fields  and BlockWrite/Read

Posted on 1998-07-04
7
319 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 50 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
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!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show Listview image from database (String field) 5 188
Multiple image collision 13 108
tidtcpserver connection lost handle 2 124
update joined tables 2 74
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

738 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