Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8608911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:44:20+00:00 2026-06-12T03:44:20+00:00

I have problem to display my Picture in TImage from my MySql database using

  • 0

I have problem to display my Picture in TImage from my MySql database using Delphi.

I save picture to my database with this code and work Perfectly.

var
  AStream : TMemoryStream;

AStream := TMemoryStream.Create;
  try
    Image1.Picture.Graphic.SaveToStream(AStream);
    AStream.Position := 0;
    if ADODataSet1.Active then
    begin
      ADODataSet1.Edit;
      TBlobField(ADODataSet1.FieldByName('MyField')).LoadFromStream(AStream);
      ADODataSet1.Post;
    end;
  finally
    AStream.Free;
  end;

But, problem is when I want to retrieve that Pictures. I use this code but I can display only first image from my database. I uses this code on DBGrid event – OnDrawColumnCell. AND WHEN I USE THIS CODE I’M GETTING MESSAGE JPEG ERROR #42!

var
  AStream : TMemoryStream;
begin
  AStream := TMemoryStream.Create;
  try
    if ADODataSet1.Active then
    begin
      TBlobField(ADODataSet1.FieldByName('MyField')).SaveToStream(AStream);
      AStream.Position := 0;
      Image1.Picture.Graphic.LoadFromStream(AStream);
    end;
  finally
    AStream.Free;
  end;
end;

Can somebody show me how to Fix This Problem.
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:44:21+00:00Added an answer on June 12, 2026 at 3:44 am

    JPEG error 42 is reported when the stream is truncated. For example, if you attempt to load a zero length file into a TJPEGImage then error 42 is the end result.

    If some images display, but not all, then the most likely explanation is that the data is somehow not making the round-trip to the DB and back.

    Check the size of the BLOB field when you write it out. Check that it tallies with the size of the file when you write it to a disk file. Check that the disk file is a valid JPEG. Then confirm that the BLOB field has the exact same length when you re-read it. Perhaps there’s something wrong with your DB code and the stream is getting truncated.

    So, the very first step here is to confirm that you can recover the exact same data that you originally put into the DB.

    The only other thought I have is that the graphic in the image control is not always a JPEG. The code that you use to load the image, Image1.Picture.Graphic.LoadFromStream() assumes that the data is a JPEG. If you had saved something other than a JPEG then LoadFromStream() would fail.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this mysql tables I want to display with jqgrid. The problem appears
I have this problem having to display my jasper report on my grails application.
I have an strange problem using two borders. I use them to display video
I'm having a problem with an image and some text. I have this code:
I am using this example to display images, stored in my File-Stream Enabled database
Here is what I have: smallURL:(@bundle://image.jpg) this line will display me a picture store
I'm using camera task to take a picture then display it. I have an
I have a problem, using presentModalViewController to display a UIView. Within the Application I
I have a problem with the display of my popover. After initWithContentViewController: and presentPopoverFromBarButtonItem:permittedArrowDirections:animated:
I have a problem with li , when I take li in inline display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.