tags:

views:

873

answers:

1

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.

A: 

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.

Doliveras
in dataset what type is given for the Fields!image_col filed?tobyte,toint,tostring...which one?
Shamim
I use System.byte() for the field that contains the image on the DataSet
Doliveras
i follow you but it show me nothing ....please share any code with me
Shamim
dataset.ImageCol = oItem.BoardImage......show me error message "Cannot implicitly convert type 'System.Drawing.Image' to 'byte' "
Shamim
I added some sample code to clarify some points
Doliveras
thanks i have already complete data take from database .....my problem is to set on collection objectDataset ds=new Dataset();DataTable dt=new DataTable()foreach(BoardImage oitem in oBoardImages){ dt.Image=oitem.Image; //This line show me error"Cannot //implicitly convert type 'System.Drawing.Image' to 'byte'" ds.DataTable1.AddDataTable1Row(dtRSS);}
Shamim
plz send me code or tutorial to show image from database to report
Shamim