' object of data row Dim drow As DataRow ' add the column in table to store the image of Byte array type dt.Columns.Add("Image", System.Type.GetType("System.Byte[]")) drow = dt.NewRow ' define the filestream object to read the image Dim fs As FileStream ' define te binary reader to read the bytes of image Dim br As BinaryReader ' check the existance of image If File.Exists(AppDomain.CurrentDomain.BaseDirectory & "10157.Jpg") Then ' open image in file stream fs = New FileStream(AppDomain.CurrentDomain.BaseDirectory & "10157.Jpg", FileMode.Open) Else ' if phot does not exist show the nophoto.jpg file fs = New FileStream(AppDomain.CurrentDomain.BaseDirectory & "FLYWELL.jpg", FileMode.Open) End If ' initialise the binary reader from file streamobject br = New BinaryReader(fs) ' define the byte array of filelength Dim imgbyte(fs.Length) As Byte ' read the bytes from the binary reader imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length))) drow(0) = imgbyte ' add the image in bytearray dt.Rows.Add(drow) ' add row into the datatable br.Close() ' close the binary reader fs.Close() ' close the file stream Dim rptobj As New CrystalReport1 ' object of crystal report rptobj.SetDataSource(dt) CrystalReportViewer1.ReportSource = rptobj 'set the report source
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)