简体   繁体   English

如何在SSRS 2008r2中将第n行字段转换为图像-Report Builder 3

[英]How can i get the nth row field into image in SSRS 2008r2 - Report Builder 3

I have a report which is just one page per record. 我有一份报告,每条记录只有一页。 The record is chosen using a parameter. 使用参数选择记录。

On this report I have space for 4 images, I have a dataset called "AdditionalPhotos". 在此报告中,我有4张图像的空间,我有一个名为“ AdditionalPhotos”的数据集。 I would like to put the image from the first four rows of this dataset into each of the spaces on the report. 我想将数据集前四行中的图像放入报表中的每个空格。

To do this, I planned on using an expression with a function like : First(Image), Second(Image), Third(Image), Fourth(Image). 为此,我计划使用具有以下功能的表达式:First(Image),Second(Image),Third(Image),Fourth(Image)。 I now realise that SSRS only supports First() and Last() so using some advice from another forum post : http://social.msdn.microsoft.com/Forums/sqlserver/en-US/20493945-578a-4d83-ae3b-e603a3473ac6/nth-row-element-in-a-dataset-ssrs 现在,我意识到SSRS仅支持First()和Last(),因此使用来自另一个论坛帖子的一些建议: http : //social.msdn.microsoft.com/Forums/sqlserver/en-US/20493945-578a-4d83-ae3b -e603a3473ac6 /数据集中的第n行元素-ssrs

I have implemented another dataset which contains the same query as the "AdditionalPhotos" but with only 2 columns "ID" and "RowNum". 我实现了另一个数据集,该数据集包含与“ AdditionalPhotos”相同的查询,但只有两列“ ID”和“ RowNum”。 Using this expression I can see a Photo Source field in a textbox, which is great, so the syntax is working. 使用此表达式,我可以在文本框中看到“照片源”字段,这很好,因此语法有效。

=Lookup(1,Fields!Row.Value,Fields!Source.Value, "AdditionalPhotos")

In the value field for the image I have : 在图像的值字段中,我有:

=Lookup(1,Fields!Row.Value,Fields!Image.Value, "AdditionalPhotos")

This doesn't work, I just get a red x icon in the image box of the report. 这行不通,我只是在报告的图像框中得到一个红色的x图标。 I have the correct MIME type setting and have confirmed this by changing the expression for the image box to : 我具有正确的MIME类型设置,并通过将图像框的表达式更改为来确认这一点:

=Fields!Image.Value

Any advice or suggestions would be great. 任何意见或建议将是巨大的。

In your SQL you can use the ROW_NUMBER() window function to generate row numbers based on an order and/or a partition so that you can select which image you want where. 在您的SQL中,您可以使用ROW_NUMBER()窗口函数根据订单和/或分区生成行号,以便您可以选择所需的图像。

Something like: 就像是:

SELECT Image,
    ROW_NUMBER() OVER(ORDER BY id) AS rownum
FROM imageTable

See: 看到:

MSDN - ROW_NUMBER (TSQL) MSDN-ROW_NUMBER(TSQL)

MSDN - OVER Clause MSDN-OVER子句

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM