Solved

Problem with BLOB field

Posted on 1997-06-23
3
319 Views
Last Modified: 2010-04-04
I'am try to save some binary data to a blob field, via a
blob stream. The problem is I get a "BLOB not opened error".
Code fragment

  }
   Table1Data is a persistent field of TBlobField Type
  {
 
   DStream := TBlobStream.Create(Form1.Table1Data,
   bmReadWrite);
   While Not EOF(DataFile) DO
     Begin
      BlockRead(DataFile,HeaderRecord,SizeOf(HeaderRecord),
                                                 NumRead);
      EndOfHeader := FilePos(DataFile);
      For i := 0 To HeaderRecord.RecCount -1 DO
       Begin
         BlockRead(DataFile,DataRecord,SizeOf(DataRecord),
                                                 NumRead);
         FieldPos := DStream.Write(DataRecord,
                             SizeOf(DataRecord));
       End;

I have no problems with the other fields in the table
0
Comment
Question by:mikedodsworth
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
Gabor earned 150 total points
ID: 1337632
The easiest way is to save the data from your datafile to the blob as a whole:var  fs: TFileStream;begin  fs:=TFileStream.Create(DataFileName,fmRead);  try    Form1.Table1Data.LoadFromStream(fs);  finally    fs.Free;  end;end;If you have to use your own code, I think you have to set table to edit state with the Edit method.
0
 
LVL 1

Expert Comment

by:Gabor
ID: 1337633
Sorry mikedodsworth, but my CR-s disappeard. I don't know why.
0
 

Author Comment

by:mikedodsworth
ID: 1337634
Gabor, I have tried putting the edit mode but it still fails.
The problem with saving the data file as whole is that
the file contains many seperate records with header info.So I
am still open to offers on the orignal code.
Thanks Mike.
 
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 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

13 Experts available now in Live!

Get 1:1 Help Now