I want to display image in crystal report from path given in database table.My code runs well but nothing is displayed in report.Below is my code.Please help me to find out the problem.
Dim Con As OdbcConnection = New OdbcConnection
Dim sql As String = "Select * from Image"
Con.ConnectionString = connstring
Dim da As OdbcDataAdapter = New OdbcDataAdapter(sql, Con)
da.Fill(ds, "Image")
ds.Tables("Image").Columns.Add("image_stream", Type.GetType("System.Byte[]"))
For index As Integer = 0 To ds.Tables("Image").Rows.Count - 1
If ds.Tables("Image").Rows(index)("image_path").ToString <> "" Then
Dim s As String = ds.Tables("Image").Rows(index)("image_path").ToString
If File.Exists(s) Then
LoadImage(ds.Tables("Image").Rows(index), "image_stream", s)
End If
End If
Next index
crDoc = New ImageReport
crDoc.SetDataSource(ds.Tables("Image"))
rptDoc.ReportSource = crDoc
Private Sub LoadImage(ByVal objDataRow As DataRow, ByVal strImageField As String, ByVal FilePath As String)
Try
Dim fs As System.IO.FileStream = New System.IO.FileStream(FilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim Image() As Byte = New Byte(fs.Length) {}
fs.Read(Image, 0, CType(fs.Length, Integer))
fs.Close()
objDataRow(strImageField) = Image
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub