Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Binary File IO and ADO

Posted on 2003-11-10
2
Medium Priority
?
450 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

715 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