locked
How To Display Image From Access Database 2007 Although All Data Display in rdlc RRS feed

  • Question

  • User1601964810 posted

    I have problem in display image from access 2007 database to rdlc

    i work in c# vs2015

    Actually i need to display image from database to more records from access 2007

    but i cannot

    in rdlc i do as following :

    In RDLC 

    drag image control to
    report source database
    mime type jpeg
    set EnableExternalImages = true
    =First(Fields!qrimg.Value, "DataSetImage") for value
    Name as Name of column in dataset .

    In dataset 

    qrimg system.Byte[]

    on database qrimg image store datatypE OLEOBJECT

    on interface 

    in button click view report

    reportViewer1.LocalReport.EnableExternalImages = true;

               
    QrClasses q = new QrClasses();

                   
    DataSetImage printexcel = q.GetDataImage();

                   
    ReportDataSource datasource = newReportDataSource("DataSetImage", printexcel.Tables[0]);

                   
    this.reportViewer1.LocalReport.DataSources.Clear();

                   
    this.reportViewer1.LocalReport.DataSources.Add(datasource);

                   
    this.reportViewer1.RefreshReport();



    using (OleDbConnection con = newOleDbConnection(connection))

               
    {

                   
    using (OleDbCommand cmd = newOleDbCommand("SELECT UserID,UserNameAR,CountryAR,MemberAR,qrimg FROM AllPrinting"))

                   
    {

                       
    using (OleDbDataAdapter sda = new OleDbDataAdapter())

                       
    {

                            cmd
    .Connection = con;

                            sda
    .SelectCommand = cmd;

                           
    using (DataSetImage dsimage = new DataSetImage())

                           
    {

                                sda
    .Fill(dsimage, "DataTable1");

                               
    return dsimage;

                           
    }
                       
    }
                   
    }
               
    }
           
    }




    Final result i can show all data from access 2007 in report but image cannot display 

    can any one help me please if possible

    i do every thing but really cannot show image .

    Wednesday, March 8, 2017 10:59 PM

Answers

  • User-2057865890 posted

    Hi Ahmed,

    To remove the OLE header from an Access image

    1. Add an image from an Access data source as described in the previous procedure.

    2. In the Image Properties dialog box, click the expression (fx) button.

    3. In the Expression dialog box, copy the following expression, with no line breaks, into the expression pane:

    =System.Convert.FromBase64String(Mid(System.Convert.ToBase64String(Fields!ImageFieldName.Value),105))

    The expression uses Mid to exclude the header information, which resides in the first 105 characters of the file, and then uses Convert to make the rest of the image base64 encoded. The expression assumes that the image originates in an EN-US database. If you are using a different collation, the OLE header might be longer or shorter than 105 characters.

    4. Click OK twice.
        An image placeholder appears on the report design surface.

    reference: https://msdn.microsoft.com/en-us/library/ms156342.aspx

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 9, 2017 1:07 AM