rdlc how to show image from database

强颜欢笑 提交于 2019-12-13 03:31:17

问题


I have a collection which contain images. I want to show those images on my RDLC report. Can anyone show me how to do that?

Please give me code or example.


回答1:


If you want to retrieve an image from a table in a database and use it in a Reporting Services report all you have to do is create a data source that contains a field with the image and use it as data source of the image field, like you do with the rest of the data you show on the report.

Imagine you have a table named image_table with a column named image_col.

All you have to do is create a data source with a select sentence like:

SELECT image_col FROM image_table WHERE your_condition_here

Once you have the data source you assign it to the image field DataSource property and assign the Fields!image_col to the Value property of the image field. With this you have the image on the report.

To test the idea you can follow this steps:

1) Define a strong typed DataSet with a table name "image_table"

2) The image_table will have 2 columns IdCol (a numeric column) and image_col a (Byte() column)

3) Fill a dataset with data using something like this:

    Dim cText As String
    Dim myDataSet As dsImageDataset

    cText = "SELECT idCol, image_col FROM image_table"
    Dim sCommand As New SqlClient.SqlCommand(cText, yourConnection)
    Dim dAdapt As New SqlClient.SqlDataAdapter(sCommand)
    dAdapt.Fill(myDataSet, "image_table")

This will fill the dataset myDataSet with all the images in the table image_table.



来源:https://stackoverflow.com/questions/1011015/rdlc-how-to-show-image-from-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!