Solved

ADO+Access2000+Images how to...

Posted on 2000-03-20
4
451 Views
Last Modified: 2010-04-04
I am trying to display images (eg. bitmaps) stored in Access database, accessed from my Delphi Application using ADO.
1. I defined field in Access table as OLE Object and embedded bitmap in there.
2. I created ADO Table and put DBImage on it.
3. When I try to link to the image field in the table I get a message
'Bitmap Image is not valid'

I don't have much time to go through the books, therefore I offer 200 points.
I will need a step-by-step instructions.

Thanx.
0
Comment
Question by:graga
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2639153
You can't use TDBImage when pictures are stored as OLE objects. Store pictures in a memo field instead.
0
 

Author Comment

by:graga
ID: 2639201
Epsylon,
I just created quickly data file with a single table, 2 fields, one memo.
I also have a very simple program that does the following:

ADOTable1.Append;
ADOTable1.FieldByName('Seq').AsInteger := 1;
ADOTable1.FieldByName('Picture').Assign(Image1.Picture);
ADOTable1.Post;

This does not work. I may need some more help please.
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 200 total points
ID: 2639215
Please ignore my previous comment. I'm mixing thing up.


You can only display bmp images with TDBImage. I used the following code to store a bmp image in an OLE object field:

var fs: TFileStream;
    bs: TBlobStream;
begin
  with ADOTable1 do
  begin
    Append;
    fs := TFileStream.Create('image1.bmp', fmOpenRead);
    bs := TBlobStream(CreateBlobStream(FieldByName('picture'), bmWrite));
    bs.CopyFrom(fs, 0);
    bs.Free;
    fs.Free;
    Post;
  end;
end;
0
 

Author Comment

by:graga
ID: 2639242
Epsylon,

You're a champion,

thanx
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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 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

18 Experts available now in Live!

Get 1:1 Help Now