Solved

Binary File IO and ADO

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Path  to current project in Delphi. 2 72
Using idhttp to login to instagram 2 76
Printing problem 2 80
Intraweb download file link ? 1 109
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now