Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 139
  • Last Modified:

About Database and Image

hello!
I want to ask a question!
if a picture's style is .JPG,
how to load the picture to a OLE field of a table?
(I'm using Microsoft Access 2000)

thanks!!!
0
Aquadp
Asked:
Aquadp
  • 5
  • 3
1 Solution
 
kretzschmarCommented:
TBlobField(table1.fieldbyname('AFieldName')).Loadfromfile; // or loadfromstream
0
 
kretzschmarCommented:
hello?
0
 
AquadpAuthor Commented:
OH!
But When i run my program,it's displaying the error dialog that it can't load the JPG image to the OLE field!

???
what happened?
how to do!
Help!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
kretzschmarCommented:
what for a control do you use for display?
0
 
AquadpAuthor Commented:
the controls of displaying are Images or DBImages.
when they were ready to load JPG images,system displayed the error dialog.

is the error belong to Delphi's Bug?
0
 
kretzschmarCommented:
hi,

jpg isn't supported by default,
therefore you can't use a tdbimage

but you can use a timage like

uses jpeg; //add jpeg into the uses clause

var
  j : TJpegImage;
  m : TMemoryStream;
begin
  j := TJpegImage.Create;
  m := TMemoryStream.Create;
  try
    if not dataset.fieldbyname('FieldName').IsNull then //only if available
    begin
      TBlobField(dataset.fieldbyname('FieldName')),SaveToStream(m);
      m.position := 0;
      j.loadfromstream(m);
      image1.picture.bitmap.assign(j);
    end;
  finally
    j.free;
    m.free;
  end;
end;

just from head,
use this code in the afterscroll-event of your dataset

meikl ;-)
 
0
 
AquadpAuthor Commented:
THANKS A LOT!
Now i see.

Good luck 4 u~~~~
0
 
kretzschmarCommented:
Good luck 4 u, too

don't forget the grade, if your question is now solved
(just press the the "accept comment" button upper right of the comment, which helped you most)

meikl ;-)
0

Featured Post

Independent Software Vendors: 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!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now