الجمعة، 13 يناير 2012

Insert picture into Report

Insert picture into report by convert picture to byte array and add to report.


1. Add picture column in ReportDataset.xsd and set data type to System.Byte() then compile project.




2. Open CustomerReport.rpt , right click Database Fields and select Verify Database menu. Insert Picture column into report.




3. At CreateDataSet function insert this code for add new picture data column.

dt.Columns.Add("Picture", Type.GetType("System.Byte[]"))

4. Create new function.

Private Function CreatePictureArray(ByVal bImagePath As String) As Byte()
Dim imgLogo As System.Drawing.Image = System.Drawing.Image.FromFile(bImagePath)

Dim msLogo As New IO.MemoryStream()
imgLogo.Save(msLogo,
System.Drawing.Imaging.ImageFormat.Bmp)


Return msLogo.ToArray()
End Function

5. Convert image to byte array and bind to datarow.

' Create new row
Dim dr As DataRow = ds.Tables(0).NewRow

dr("Title") = "Mr"

dr("FirstName") = "Tom"
dr("LastName") = "Brown"

dr("Address") = "Tom Address"

dr("Picture") = CreatePictureArray("c:\person.jpg")

6. Show Report

Source: http://vbnetsample.blogspot.com/2008/06/insert-picture-into-report.html

free c programming software download c programming software free download free download c programming software free computer programming software c programming free download free download c programming c programming download free free programming ebooks how to learn c# how to c#

ليست هناك تعليقات:

إرسال تعليق