Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Binary File IO and ADO

Posted on 2003-11-10
2
Medium Priority
?
452 Views
Last Modified: 2010-04-05
Hi,

I need to read a binary file into memory and insert it into my DB (via ADO). (I have never done IO in Delphi before.) Can anyone give me a piece of code to read a binary file into memory (efficiently) and also show me the best way to insert it into the DB...

Thanks a lot,
Marius
0
Comment
Question by:BarCode99
2 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 500 total points
ID: 9716394
-define a blob-field in your table
use
Dataset.edit; //or insert
TBlobField(Dataset.FieldByName('YourFieldNameHere')).LoadFromFile('YourFileNameHere');
Dataset.Post;

if you need to load into memory

var
  ms : TMemoryStream;
begin
  ms := TMemoryStream.Create;
  try
    ms.LoadFromFile('YourFileNameHere');
    //maybe some processing with the in memory content
    ms.Position := 0; //spool back
    Dataset.edit; //or insert
    TBlobField(Dataset.FieldByName('YourFieldNameHere')).LoadFromStream(ms);
    Dataset.Post;
  finally
    ms.free;
  end;
end;

hope this helps

meikl ;-)
0
 

Author Comment

by:BarCode99
ID: 9717038
Thanks meikl!

As usual you solve my problem...

Mairus
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

927 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