Solved

Binary File IO and ADO

Posted on 2003-11-10
2
447 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 125 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month3 days, 23 hours left to enroll

630 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