Home > database >  Passing Barcode to report.rdlc through parameter in .vb
Passing Barcode to report.rdlc through parameter in .vb

Time:12-02

I have a barcode in PictureBox1 and I want to pass it over to the image in report.rdlc through parameters but since the barcode is not a typical image like .png, .jpg, etc. I am getting an error “value should not be null” but it works with .png image though.

Here’s my code:

Dim ms As New MemoryStream
        Form1.PictureBox1.Image.Save(ms, Form1.PictureBox1.Image.RawFormat)
        Dim arrPic As Byte()
        arrPic = ms.ToArray
        Dim images As String = Convert.ToBase64String(arrPic)

    Dim param As IList(Of ReportParameter) = New List(Of ReportParameter)
    param.Add(New ReportParameter("Address", Form1.TextBox4.Text))
    param.Add(New ReportParameter("img", images, True))     
  ReportViewer1.LocalReport.SetParameters(param)
   Me.ReportViewer1.RefreshReport()

CodePudding user response:

You add an image to your RDLC report and set the following properties of the image:

MIMEType <to your image's mime type> Ex image/png, image/jpeg, etc
Source = Database
Value = =System.Convert.FromBase64String(Parameters!img.Value)
  • Related