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.
LVL 6
Stuart_JohnsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Stuart_JohnsonAuthor Commented:
Edited text of question.
0
interCommented:
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
0
men xinCEOCommented:

Var stmData: TblobStream;
    stmFile: TFileStream;
begin
   stmFile := TFileStream.Create('C:\COMMAND.COM', fmOpenRead);
   tbProducts.Append;
   stmData :=Tblobstream.create(tbProducts.FieldByName('Data'), bmWrite);
   stmData.CopyFrom(stmFile, stmFile.Size);
   tbProducts.Post;
   stmData.Free;
   stmFile.Free;
End;


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Stuart_JohnsonAuthor Commented:
Thanks menxin, I am honestly not with it today.  I can't believe I overlooked that!

Working wonderfully now!

Stu.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.