Solved

Problem with BLOB field

Posted on 1997-06-23
3
322 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

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 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

11 Experts available now in Live!

Get 1:1 Help Now