rdlc如何显示数据库中的图像 [英] rdlc how to show image from database

查看:49
本文介绍了rdlc如何显示数据库中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含图像的集合.我想在我的 RDLC 报告中显示这些图像.谁能告诉我怎么做?

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?

请给我代码或示例.

推荐答案

如果您想从数据库中的表中检索图像并在 Reporting Services 报表中使用它,您只需创建一个数据源,其中包含一个带有图像的字段,并将其用作图像字段的数据源,就像处理报告中显示的其余数据一样.

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.

假设您有一个名为 image_table 的表,其中有一列名为 image_col.

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

获得数据源后,将其分配给图像字段的 DataSource 属性,并将 Fields!image_col 分配给图像字段的 Value 属性.有了这个,您就可以在报告中看到图片了.

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.

要测试这个想法,您可以按照以下步骤操作:

1) 定义一个表名为image_table"的强类型数据集

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

2) image_table 将有 2 列 IdCol(数字列)和 image_col a(Byte() 列)

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

3) 使用如下方式用数据填充数据集:

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")

这将使用表 image_table 中的所有图像填充数据集 myDataSet.

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

这篇关于rdlc如何显示数据库中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆