C# RDLC report viewer - Displaying multiple Images from Database - not working

27 views Asked by At

I need to build a report viewer that has a contents of multiple data, including Images (mediumBlob) data field from MySQL database (not image path). I created a Dataset that contains multiple tables of data then feed them to the report viewer. The image field is set to System.Byte[] of course. enter image description here All the data is viewing fine but only the images got error like this: enter image description here

My code:

    private void finMOM_Load(object sender, EventArgs e)
    {
        DateTime today = DateTime.Today;
        string year = today.Year.ToString();
        string month = today.Month.ToString();
        string day = today.Day.ToString();
        tbxSubject.Text = $"[{ProjectCode}] MOM{year}{month}{day}";

        rpvMOM.LocalReport.DataSources.Clear();
        DataTable mom = MOMDAO.Instance.LoadMOMByID(MomID);
        DataTable attendee = AttendeeDAO.Instance.LoadAttendee(MomID);
        DataTable matter = MatterDAO.Instance.LoadMatter(MomID);
        ReportDataSource momds = new ReportDataSource("MOM", mom);
        ReportDataSource attendeeds = new ReportDataSource("Attendee", attendee);
        ReportDataSource matterds = new ReportDataSource("Matter", matter);
        rpvMOM.LocalReport.ReportPath = "inMOM.rdlc";
        rpvMOM.LocalReport.DataSources.Add(momds);
        rpvMOM.LocalReport.DataSources.Add(attendeeds);
        rpvMOM.LocalReport.DataSources.Add(matterds);
        rpvMOM.RefreshReport();
    }

Please help me solve this somehow. Thank you in advance.

It should be like this: enter image description here

1

There are 1 answers

0
Hoàng Nguyễn On

I have figured out the solution, actually quite simple:

  1. Add image inside a table from toolbox: Add image inside the data field of the table

  2. Change Image properties to fit your need: Properties image

  3. Results: Awsome!