Create a BLOB field in database with a column Name
COLUMNNAME.
Use the following code for getting the reference of the image
Private Function authSign(ByVal doccode As String) As DataTable
'here i have define a simple datatable inwhich image will recide
Dim dt As New DataTable()
'object of data row
Dim drow As DataRow
' add the column in table to store the image of Byte array type
dt.Columns.Add("COLUMNNAME", 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 + "\Lab Reports\Signatures\" + doccode + ".JPG")) Then
' open image in file stream
fs = New FileStream(AppDomain.CurrentDomain.BaseDirectory + "\Lab Reports\Signatures\" + doccode + ".JPG", FileMode.Open)
Else
' if phot does not exist show the nophoto.jpg file
fs = New FileStream(AppDomain.CurrentDomain.BaseDirectory + "\Lab Reports\Signatures\noSign.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 + 1) As Byte
' read the bytes from the binary reader
imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)))
drow("COLUMNNAME") = 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
Return dt
End Function
Returned Datatable can be passed as a sourse to ur report or ur subreport.Here i used subreport
of report name AuthSignature.rpt in my main report
Dim report1 As New ReportDocument
Dim auth As New DataTable
auth.Columns.Add("COLUMNNAME", System.Type.GetType("System.Byte[]"))
auth = authSign(OrderDtlType.t_ILS_ORDTAUTHDOCTORCODE)
report1.Subreports("AuthSignature.rpt").SetDataSource(auth)
CrystalReportViewer_rad.ReportSource = report1
CrystalReportViewer_rad.DataBind()