Link to home
Start Free TrialLog in
Avatar of Stuart_Johnson
Stuart_Johnson

asked on

CreateBlobStream Question

Hi.

I need to save some binary files within a Paradox 7 database.  I have created the database using the Database desktop and set the field type as Binary.  However, when I try to copy the file into the Binary field, I get a stream write error.

Here's the code I am using:

Var stmData: TStream;
    stmFile: TFileStream;

begin
   stmFile := TFileStream.Create('C:\COMMAND.COM', fmOpenRead);
   stmData := tbProducts.CreateBlobStream(tbProducts.FieldByName('Data'), bmReadWrite);
   tbProducts.Append;
   stmData.CopyFrom(stmFile, stmFile.Size);
   tbProducts.Post;
   stmData.Free;
   stmFile.Free;
End;

What am I doing wrong??

Thanks for any help,

Stu.
Avatar of Stuart_Johnson
Stuart_Johnson

ASKER

Edited text of question.
Hi Stu,

In which one you get an error? Command.com could be locked so may be we may use
TFileStream.Create('C:\COMMAND.COM', fmOpenRead or fmShareDenyNone);
or
TFileStream.Create('C:\COMMAND.COM', fmOpenRead or fmShareCompat);

igor
ASKER CERTIFIED SOLUTION
Avatar of men xin
men xin
Flag of China image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks menxin, I am honestly not with it today.  I can't believe I overlooked that!

Working wonderfully now!

Stu.