3

I tried various methods given online to insert an image in Crystal Reports dynamically from database but it did not work for me. The Image is still not getting displayed. I have tried doing it by using database expert, dataset and setting graphic location for a picture field but still no result. I have tried all methods possible I could find online.

I am using VS 2013 as my front end, SQL Server 2008 as back end and Crystal Reports version 13.

Thank you in advance

2
  • Where exactly would you have the images? (stored in database, stored in server with path stored in database, ...) Commented Apr 15, 2016 at 6:05
  • images are stored in image datatype on the database Commented Apr 15, 2016 at 6:59

2 Answers 2

0

Since VS 2013 open your rpt file (not the cs code associated), over this, click with secondary button and select insert -> image -> browse in your computer image file. Later at moment to open the image you will paste in the rpt file (you will view first a rectangle with preliminar location of the image). In this way your image file will be converted to OLE Object inside rpt file (cristal reports file inside VS2013 Project).

Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your reply, but i need dynamic images from database
0

In order to use Blob image on Crystal report you need to pass byte / binary data from c# inside your dataset that you are connecting to report rpt file. check below suggestion if you have path of image file retrieved from database

Add Image Property to dataset with Type in byte. this property will be placed on crystral report from dataset on report

ds.Tables[0].Columns.Add("Image", typeof(byte[]));

Below code is for converting the image from a path to Byte to transfer it to .rpt file that has blob type field for this.

string path12 = "path of image from database";
       
        FileStream fs19 = null;
        try
        {
            fs19 = new FileStream(path12, FileMode.Open);
            using (BinaryReader br19 = new BinaryReader(fs19))
            {
                byte[] imgbyte = br19.ReadBytes((int)fs19.Length);
                ds.Tables[0].Rows[i]["Image"] = imgbyte;
                fs19 = null;
            }
        }
        catch (Exception)
        {
            // Handle exception if needed
        }
        finally
        {
            if (fs19 != null)
            {
                fs19.Dispose();
            }
        }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.