<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A Developer&#039;s Blog &#187; Reporting Services</title>
	<atom:link href="http://blog.hoegaerden.be/tag/reporting-services/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hoegaerden.be</link>
	<description>SQL Server, BI, .NET, IT and anything else I have been playing with.</description>
	<lastBuildDate>Wed, 01 Sep 2010 06:27:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Put Some Images On Those SSRS Reports</title>
		<link>http://blog.hoegaerden.be/2010/07/07/put-some-images-on-those-ssrs-reports/</link>
		<comments>http://blog.hoegaerden.be/2010/07/07/put-some-images-on-those-ssrs-reports/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 16:05:21 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[Reporting Services 2008]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2010/07/07/put-some-images-on-those-ssrs-reports/</guid>
		<description><![CDATA[On the forums I now and then encounter questions regarding images on SSRS reports.&#160; Instead of re-inventing the wheel each time, I decided to write an article about the subject.&#160; So in this article I’ll be discussing and demonstrating several different ways of how images can be put on a report.
I’m using SQL Server Reporting [...]]]></description>
			<content:encoded><![CDATA[<p>On the forums I now and then encounter questions regarding images on SSRS reports.&#160; Instead of re-inventing the wheel each time, I decided to write an article about the subject.&#160; So in this article I’ll be discussing and demonstrating several different ways of how images can be put on a report.</p>
<p>I’m using SQL Server Reporting Services 2008 R2 CTP, more precisely version 10.50.1352.12, but the methods explained here will work on any SSRS 2008.&#160; Furthermore I’m using the AdventureWorks2008R2 database, <a title="AdventureWorks 2008R2 RTM" href="http://msftdbprodsamples.codeplex.com/releases/view/45907" target="_blank">available at CodePlex</a>.</p>
<p>The resulting report, including image files, <a title="SSRS and images download" href="http://cid-81c8b064cbbe1698.office.live.com/self.aspx/.Public/blog/SSRS%5E_and%5E_images.zip" target="_blank">can be downloaded from my Skydrive</a>.</p>
<h2>The Scenario</h2>
<p>The marketing department has requested a product catalogue.&#160; This catalogue should contain all products produced by our two daughter companies: The Canyon Peak and Great Falls Soft.&#160; The catalogue should be grouped on company, with the next company&#8217;s products starting on a new page.</p>
<p>Further requirements are:</p>
<ol>
<ol>
<li>Each page needs an image in its header, with even pages displaying a different image than odd pages. </li>
<li>Each company has a logo.&#160; The logo should be displayed in the company’s header. </li>
<li>Each product has a logo.&#160; The logo should be displayed as part of the product details. </li>
</ol>
</ol>
<p>A design document containing the expected layout, including all image material, has been provided.</p>
<h2>The Data</h2>
<p>The following query provides us with all the data needed to produce the report:</p>
<p> <a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a>
<pre class="code"><span style="color: blue">SELECT </span><span style="color: red">'The Canyon Peak' </span><span style="color: blue">as </span>Company<span style="color: gray">, </span><span style="color: red">'TheCanyonPeak_logo.png' </span>CompanyLogo<span style="color: gray">,
    </span><span style="color: red">'The Canyon Peak company specializes in all kinds of bikes, such as touring and road bikes.' </span>CompanyDescription<span style="color: gray">,
    </span>P<span style="color: gray">.</span>Name <span style="color: blue">as </span>Product<span style="color: gray">, </span>PS<span style="color: gray">.</span>Name <span style="color: blue">as </span>Subcategory<span style="color: gray">, </span>PC<span style="color: gray">.</span>Name <span style="color: blue">as </span>Category<span style="color: gray">,
    </span>PP<span style="color: gray">.</span>LargePhoto<span style="color: gray">, </span>P<span style="color: gray">.</span>ListPrice<span style="color: gray">, </span>P<span style="color: gray">.</span><span style="color: blue">Weight</span><span style="color: gray">, </span>P<span style="color: gray">.</span>Size<span style="color: gray">,
    </span>P<span style="color: gray">.</span>SizeUnitMeasureCode<span style="color: gray">, </span>P<span style="color: gray">.</span>WeightUnitMeasureCode
<span style="color: blue">FROM </span>Production<span style="color: gray">.</span>Product <span style="color: blue">AS </span>P
    <span style="color: gray">INNER JOIN </span>Production<span style="color: gray">.</span>ProductSubcategory <span style="color: blue">AS </span>PS
        <span style="color: blue">ON </span>PS<span style="color: gray">.</span>ProductSubcategoryID <span style="color: gray">= </span>P<span style="color: gray">.</span>ProductSubcategoryID
    <span style="color: gray">INNER JOIN </span>Production<span style="color: gray">.</span>ProductCategory <span style="color: blue">AS </span>PC
        <span style="color: blue">ON </span>PC<span style="color: gray">.</span>ProductCategoryID <span style="color: gray">= </span>PS<span style="color: gray">.</span>ProductCategoryID
    <span style="color: gray">LEFT OUTER JOIN </span>Production<span style="color: gray">.</span>ProductProductPhoto PPP
        <span style="color: blue">ON </span>PPP<span style="color: gray">.</span>ProductID <span style="color: gray">= </span>P<span style="color: gray">.</span>ProductID
    <span style="color: gray">LEFT OUTER JOIN </span>Production<span style="color: gray">.</span>ProductPhoto PP
        <span style="color: blue">ON </span>PPP<span style="color: gray">.</span>ProductPhotoID <span style="color: gray">= </span>PP<span style="color: gray">.</span>ProductPhotoID
<span style="color: blue">WHERE </span>PC<span style="color: gray">.</span>Name <span style="color: gray">= </span><span style="color: red">'Bikes' </span><span style="color: green">--The Canyon Peak sells bikes
    </span><span style="color: gray">and </span>PP<span style="color: gray">.</span>ProductPhotoID <span style="color: gray">&gt; </span>1 <span style="color: green">--I don't want NO IMAGE AVAILABLE
</span><span style="color: blue">UNION </span><span style="color: gray">ALL
</span><span style="color: blue">SELECT </span><span style="color: red">'Great Falls Soft' </span><span style="color: blue">as </span>Company<span style="color: gray">, </span><span style="color: red">'GreatFallsSoft_logo.png' </span>CompanyLogo<span style="color: gray">,
    </span><span style="color: red">'Great Falls Soft uses only the softest tissues available for those sporting clothes.  And on top of that, they''re waterproof.' </span>CompanyDescription<span style="color: gray">,
    </span>P<span style="color: gray">.</span>Name <span style="color: blue">as </span>Product<span style="color: gray">, </span>PS<span style="color: gray">.</span>Name <span style="color: blue">as </span>Subcategory<span style="color: gray">, </span>PC<span style="color: gray">.</span>Name <span style="color: blue">as </span>Category<span style="color: gray">,
    </span>PP<span style="color: gray">.</span>LargePhoto<span style="color: gray">, </span>P<span style="color: gray">.</span>ListPrice<span style="color: gray">, </span>P<span style="color: gray">.</span><span style="color: blue">Weight</span><span style="color: gray">, </span>P<span style="color: gray">.</span>Size<span style="color: gray">,
    </span>P<span style="color: gray">.</span>SizeUnitMeasureCode<span style="color: gray">, </span>P<span style="color: gray">.</span>WeightUnitMeasureCode
<span style="color: blue">FROM </span>Production<span style="color: gray">.</span>Product <span style="color: blue">AS </span>P
    <span style="color: gray">INNER JOIN </span>Production<span style="color: gray">.</span>ProductSubcategory <span style="color: blue">AS </span>PS
        <span style="color: blue">ON </span>PS<span style="color: gray">.</span>ProductSubcategoryID <span style="color: gray">= </span>P<span style="color: gray">.</span>ProductSubcategoryID
    <span style="color: gray">INNER JOIN </span>Production<span style="color: gray">.</span>ProductCategory <span style="color: blue">AS </span>PC
        <span style="color: blue">ON </span>PC<span style="color: gray">.</span>ProductCategoryID <span style="color: gray">= </span>PS<span style="color: gray">.</span>ProductCategoryID
    <span style="color: gray">LEFT OUTER JOIN </span>Production<span style="color: gray">.</span>ProductProductPhoto PPP
        <span style="color: blue">ON </span>PPP<span style="color: gray">.</span>ProductID <span style="color: gray">= </span>P<span style="color: gray">.</span>ProductID
    <span style="color: gray">LEFT OUTER JOIN </span>Production<span style="color: gray">.</span>ProductPhoto PP
        <span style="color: blue">ON </span>PPP<span style="color: gray">.</span>ProductPhotoID <span style="color: gray">= </span>PP<span style="color: gray">.</span>ProductPhotoID
<span style="color: blue">WHERE </span>PC<span style="color: gray">.</span>Name <span style="color: gray">= </span><span style="color: red">'Clothing' </span><span style="color: green">--Great Falls Soft sells clothes, waterstopping soft clothes
    </span><span style="color: gray">and </span>PP<span style="color: gray">.</span>ProductPhotoID <span style="color: gray">&gt; </span>1 <span style="color: green">--I don't want NO IMAGE AVAILABLE
</span><span style="color: blue">ORDER BY </span>Category <span style="color: blue">asc</span><span style="color: gray">, </span>Subcategory <span style="color: blue">asc</span><span style="color: gray">, </span>Product <span style="color: blue">asc</span><span style="color: gray">;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>I’m not going into the details of this query.&#160; Let’s just say that I’m manipulating data from the database in combination with some hardcoded data to get usable data for our example.&#160; I’ve added some comments to make it clear what the query is doing.&#160; If you have a look at its output, you’ll see that it produces a list of products with some additional fields.</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/image303.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Results of the query" border="0" alt="Results of the query" src="http://blog.hoegaerden.be/wp-content/uploads/image_thumb71.png" width="700" height="72" /></a> </p>
<h2>Different Ways Of Adding Images</h2>
<p>To get started, open up a SSRS solution, add a new report, add a data source connecting to your AdventureWorks 2008 R2 DB, and add a dataset using the above query.</p>
<h3>Embedding Images In Your Report</h3>
<p>The first way of adding images to a report that we’ll take a look at is by embedding them inside the report.&#160; Looking at the scenario requirements described earlier, this is requirement 1.</p>
<p>Let’s add a header to the report.&#160; In the BIDS menu, select <strong>Report</strong> &gt; <strong>Add Page Header</strong>.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Adding a header to a report" border="0" alt="Adding a header to a report" src="http://blog.hoegaerden.be/wp-content/uploads/image304.png" width="265" height="178" /> </p>
<p>If you don’t see the Report menu item, you probably have not selected your report.&#160; Click your report in the Design view to select it.</p>
<p>From the Toolbox, drag the Image report item onto the header portion of the report.&#160; Doing that will show a pop-up window, the Image Properties.&#160; By default, the <strong>Select the image source </strong>combobox is set to <em>Embedded</em>.&#160; Good, that’s what we need at this point.&#160; What we now need to do is import an image into the report, using the <strong>Import</strong> button.</p>
<p>Clicking the Import button shows a common file Open dialog.&#160; Our marketing department has given me two images for use in the header: Cloudy_banner.png and AnotherCloudy_banner.png.&#160; Let’s select the first one.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Adding an image to a report by using the Import button on the Image Properties window" border="0" alt="Adding an image to a report by using the Import button on the Image Properties window" src="http://blog.hoegaerden.be/wp-content/uploads/image305.png" width="625" height="434" /> </p>
<p>If you don’t see any images, have a look at that filter dropdown as highlighted in the screenshot above.&#160; By default this is set to JPEG files.</p>
<p>Here’s the result in the Image Properties:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Image Properties with an image selected" border="0" alt="Image Properties with an image selected" src="http://blog.hoegaerden.be/wp-content/uploads/image306.png" width="585" height="532" /> </p>
<p>On the Size page, select <em>Clip</em> instead of <em>Fit proportional</em>.&#160; This is a setting that you’ll need to look at case per case.&#160; For our header images, <em>Clip</em> is the most suitable option.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Image Properties: set Display to Clip" border="0" alt="Image Properties: set Display to Clip" src="http://blog.hoegaerden.be/wp-content/uploads/image307.png" width="585" height="532" /> </p>
<p>Close the Image Properties window and enlarge the image placeholder so that it occupies the whole header area:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Image added to report header" border="0" alt="Image added to report header" src="http://blog.hoegaerden.be/wp-content/uploads/image308.png" width="544" height="180" /> </p>
<p>As you can see, we now have an image in the header.&#160; But we haven’t fully implemented the requirement yet.&#160; The even pages should display a different image than the uneven ones.</p>
<p>To be able to do that, we’ll first add the second banner image to the report.&#160; In the Report Data pane, locate the <em>Images</em> node and open it up.&#160; You’ll notice that the image that we inserted earlier can be found here.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="The Images node in the Report Data pane shows all embedded images" border="0" alt="The Images node in the Report Data pane shows all embedded images" src="http://blog.hoegaerden.be/wp-content/uploads/image309.png" width="168" height="159" /> </p>
<p>Right-click the <em>Images</em> node and select <strong>Add Image</strong>.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Right-click Images node to add an embedded image to the report" border="0" alt="Right-click Images node to add an embedded image to the report" src="http://blog.hoegaerden.be/wp-content/uploads/image310.png" width="229" height="155" /> </p>
<p>That opens up the familiar file Open dialog which was used to add the first image.&#160; So I’m now selecting the file called AnotherCloudy_banner.png, after changing the default filter to PNG.&#160; After clicking OK, the image gets added under the Images node.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Second banner image added to the report" border="0" alt="Second banner image added to the report" src="http://blog.hoegaerden.be/wp-content/uploads/image311.png" width="190" height="64" />&#160; </p>
<p>With the second image added, all that remains to be done is tell the header that it should pick different images depending on the page number.</p>
<p>Right-click the image in the header and select <strong>Image Properties</strong>.&#160; On the General page, when you click the dropdown of the setting called Use this image, you’ll notice that there are two values now.&#160; These are the same values as displayed in the Report Data pane.&#160; And these are the values to be used in the expression that we’ll create to rotate the images depending on page number.</p>
<p>Click the fx button next to the dropdown and enter the following expression:</p>
<pre class="code">=IIF(Globals!PageNumber <span style="color: blue">Mod </span>2 = 0, <span style="color: #a31515">&quot;Cloudy_banner&quot;</span>, <span style="color: #a31515">&quot;AnotherCloudy_banner&quot;</span>)</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>This is a fairly simple expression, using the Mod operator and the IIF() function.&#160; When page number can be divided by two, which means it’s an even page number, Cloudy_banner is displayed.&#160; Otherwise the other banner is displayed.</p>
<p>That’s it, the report header is finished.&#160; When you have a look at the report in Preview, it should now show the second banner on the first page – this is an uneven page.</p>
<p>To conclude this chapter I’d like to mention that this method is usually not the preferred one.&#160; A <strong>disadvantage</strong> here is that the images are stored inside the report RDL and thus cannot be modified without altering the report itself.</p>
<p>Here’s the evidence:</p>
<pre class="code"> <span style="color: blue">&lt;</span><span style="color: #a31515">EmbeddedImages</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">EmbeddedImage </span><span style="color: red">Name</span><span style="color: blue">=</span>&quot;<span style="color: blue">Cloudy_banner</span>&quot;<span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">MIMEType</span><span style="color: blue">&gt;</span>image/png<span style="color: blue">&lt;/</span><span style="color: #a31515">MIMEType</span><span style="color: blue">&gt;
      &lt;</span><span style="color: #a31515">ImageData</span><span style="color: blue">&gt;</span>iVBORw0KGgoAAAANSUhEUgAABVsAAABaCAIAAA...</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>To have a look at the RDL yourself, just right-click the report in the <strong>Solution Explorer</strong> and select <em>View Code</em>.</p>
<p>On to requirement number two!</p>
<h3>Displaying Images Through A URL</h3>
<p>At the moment, the report body is still empty, so drag a Table onto it.&#160; Put the Table in the upper-left corner, remove one of the columns so that two remain, remove the Header row and make it a bit wider.</p>
<p>Now set the <strong>DataSetName</strong> property of the Tablix to the name of your dataset, in my case that’s <em>dsProducts</em>.</p>
<p>The report should display the data grouped on company, so right-click on the line that says <em>Details</em> in the Row Groups window part at the bottom of the Design View.&#160; Select <strong>Add Group &gt; Parent Group</strong>.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Right-click the Details line in Row Groups to add a new parent group" border="0" alt="Right-click the Details line in Row Groups to add a new parent group" src="http://blog.hoegaerden.be/wp-content/uploads/image312.png" width="646" height="160" /> </p>
<p>Group by Company and add a group header:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Tablix grouping" border="0" alt="Tablix grouping" src="http://blog.hoegaerden.be/wp-content/uploads/image313.png" width="451" height="201" /> </p>
<p>Remove the extra first column that just got generated:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Remove unwanted column" border="0" alt="Remove unwanted column" src="http://blog.hoegaerden.be/wp-content/uploads/image314.png" width="646" height="189" /> </p>
<p>We’ve now got an empty tablix with two columns, a Details row and a Company header row.&#160; In our dataset, one of the fields is called <em>CompanyDescription</em>.&#160; Hover the mouse pointer above the textbox in the top-right, click the small icon that appears and choose the field from the dropdown that appears when you click the icon.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Click the small icon to get a list of fields" border="0" alt="Click the small icon to get a list of fields" src="http://blog.hoegaerden.be/wp-content/uploads/image315.png" width="299" height="64" /> </p>
<p>To add the company’s logo, drag an Image from the Toolbox pane into the textbox on the left of the company description.&#160; Doing this opens up the by now familiar Image Properties dialog.</p>
<p>Give it a good name, such as CompanyLogo, and select <em>External</em> as image source.</p>
<p>Click the fx button next to the <strong>Use this image</strong> box and enter an expression such as this one:</p>
<pre class="code">=<span style="color: #a31515">&quot;file:C:\vavr\test\&quot; </span>+ Fields!CompanyLogo.Value</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>When using External as image source, the image expression should result in a valid URL, any valid URL.&#160; In my example the files are located in a local folder called c:\vavr\test.&#160; Keep in mind that, when you deploy the report to a server, the images should by located in that same folder, this time located on the server.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="The Image Properties configured to display an External image" border="0" alt="The Image Properties configured to display an External image" src="http://blog.hoegaerden.be/wp-content/uploads/image316.png" width="417" height="200" /> </p>
<p>By default the image gets displayed using the <em>Fit Proportional </em>setting.&#160; You can verify this in the <strong>Size</strong> page of the Image Properties.&#160; We want the image to get fully displayed while maintaining the aspect ratio, so leave the setting as it is.&#160; Close the image properties dialog.</p>
<p>Vertically enlarge the first row in our tablix to an acceptable size.&#160; In my case the marketing department specified to use a height of 1.5 inches for the company logo.&#160; With the image selected, locate the Size &gt; Height property and set it to “1,5in”.&#160; Note that the decimal separator used here depends on your local settings.</p>
<p>Now have a look at the report in Preview:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="The report with company logos added" border="0" alt="The report with company logos added" src="http://blog.hoegaerden.be/wp-content/uploads/image317.png" width="664" height="328" /> </p>
<p>Note that I’ve removed the borders of all textboxes by setting their <strong>BorderStyle </strong>property to <em>None</em>.</p>
<p>With the logo images implemented we have fulfilled requirement two.&#160; On to number three.</p>
<h3>Retrieving Images From The Database</h3>
<p>In this last requirement we’ll have a look at displaying images that are retrieved from the database, also known as data-bound images.</p>
<p>The retrieving part is actually already implemented.&#160; In our dataset there’s a field called <strong>LargePhoto</strong>, that one contains a picture of the product.</p>
<p>Let’s add some product details and a picture in that remaining blank row.&#160; To get full control over layout I want to make the detail part of the tablix a freestyle part.&#160; First merge the two cells together by selecting both of them, then right-click and choose <strong>Merge Cells</strong>.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Merging two cells together in a tablix" border="0" alt="Merging two cells together in a tablix" src="http://blog.hoegaerden.be/wp-content/uploads/image318.png" width="686" height="632" /> </p>
<p>Now select a <strong>Rectangle</strong> in the Toolbox pane and drop it into the merged area.&#160; To add fields such as Subcategory and Product you can just select them from the <strong>Report Data </strong>pane and drop them inside the rectangle.&#160; I’m also adding some additional labels and fields, as shown in the next screenshot.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="The product details in Design view" border="0" alt="The product details in Design view" src="http://blog.hoegaerden.be/wp-content/uploads/image319.png" width="347" height="196" /> </p>
<p>As you can see I’ve modified the fonts a bit.&#160; The rendered version:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="The rendered product details" border="0" alt="The rendered product details" src="http://blog.hoegaerden.be/wp-content/uploads/image320.png" width="306" height="187" /> </p>
<p>This is the expression used for displaying the weight:</p>
<pre class="code">=IIF(
    IsNothing(Fields!Weight.Value),
    <span style="color: #a31515">&quot;unknown&quot;</span>,
    Fields!Weight.Value &amp; <span style="color: #a31515">&quot; &quot; </span>&amp; Fields!WeightUnitMeasureCode.Value
)</pre>
<p><a href="http://11011.net/software/vspaste"></a>And here’s the expression for the size field:</p>
<pre class="code">=Fields!Size.Value &amp; <span style="color: #a31515">&quot; &quot; </span>&amp; Fields!SizeUnitMeasureCode.Value</pre>
<p><a href="http://11011.net/software/vspaste"></a>For the layout the price field I’ve just entered C in the <strong>Format</strong> property of the textbox.</p>
<p>With the textual product details completed, all that remains to be done is adding the product image.</p>
<p>From the Toolbox pane, drag an <strong>Image</strong> into the remaining whitespace in the rectangle, next to the product details.&#160; (You did keep some space available, right?)</p>
<p>Again we get the familiar Image Properties popup.&#160; Give it a good name, like ProductImage, and select the image source that we haven’t used yet, <em>Database</em>.&#160; In the <strong>Use this field </strong>dropdown, select <em>LargePhoto</em>, and select <em>image/gif</em> as <strong>MIME type</strong>.</p>
<p><strong>Note:</strong> the images are stored as GIF.&#160; You can verify this by running a select on the Production.ProductPhoto table.&#160; Looking at the LargePhotoFileName field we see that the extension is .gif.</p>
<p>There one textbox on the General page that’s still blank.&#160; That one is called Tooltip.&#160; Click the fx button next to it and enter following formula:</p>
<pre class="code">=Fields!Product.Value</pre>
<p><a href="http://11011.net/software/vspaste"></a>Click sufficient OK buttons until the properties dialog is gone, then resize the image placeholder so that it occupies the remaining whitespace.</p>
<p>Here’s what the result looks like in preview:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="The final report, with a tooltip on the product image" border="0" alt="The final report, with a tooltip on the product image" src="http://blog.hoegaerden.be/wp-content/uploads/image321.png" width="656" height="344" /> </p>
<p>When hovering the mouse pointer above the product image, you’ll get a nice tooltip.</p>
<h2>Conclusion</h2>
<p>In this article I have illustrated the three possible methods of adding an image to your Reporting Services report.</p>
<p>Have fun!</p>
<p>Valentino.</p>
<p><strong>References</strong></p>
<p><a title="Adding Images to a Report" href="http://msdn.microsoft.com/en-us/library/ms156482.aspx" target="_blank">BOL: Adding Images to a Report</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2010/07/07/put-some-images-on-those-ssrs-reports/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The value provided for the report parameter is not valid for its type</title>
		<link>http://blog.hoegaerden.be/2009/08/26/the-value-provided-for-the-report-parameter-is-not-valid-for-its-type/</link>
		<comments>http://blog.hoegaerden.be/2009/08/26/the-value-provided-for-the-report-parameter-is-not-valid-for-its-type/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 19:06:13 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2009/08/26/the-value-provided-for-the-report-parameter-is-not-valid-for-its-type/</guid>
		<description><![CDATA[While building parameterized reports in SQL Server Reporting Services 2005 you may come across the following error when viewing the report in Preview.
An error occurred during local report processing.
The value provided for the report parameter ‘YourParameter’ is not valid for its type.
I encountered this error even though I had not specified a default value for [...]]]></description>
			<content:encoded><![CDATA[<p>While building parameterized reports in SQL Server Reporting Services 2005 you may come across the following error when viewing the report in Preview.</p>
<blockquote><p>An error occurred during local report processing.</p>
<p>The value provided for the report parameter ‘YourParameter’ is not valid for its type.</p></blockquote>
<p>I encountered this error even though I had not specified a default value for the parameter.  So how can it be not valid if it doesn’t exist?</p>
<p>I found a perfect solution in <a title="How do I resolve the error &quot;the value provided for the report parameter is not valid for its type&quot;?" href="http://www.datagonewild.com/ssrs-help/errors-and-known-bugs/how-do-i-resolve-the-error-the-value-provided-for-the-report.html" target="_blank">this little article</a>.</p>
<p>Apparently it has something to do with the <strong>Allow blank value</strong> checkbox.  In my report the data type for my parameter was Integer.  And as explained in the mentioned article, the <strong>Allow blank value</strong> checkbox is checked and greyed out.  Luckily the little trick of switching to String, unchecking the checkbox and switching back to Integer solves the error.</p>
<p>But why?  How come that an error occurs due to a setting that is greyed out?  A greyed out setting, doesn’t that mean that its value is not applicable in combination with the other settings?  Apparently not.  Well, I guess that’s a bug then, right?</p>
<p>If someone has a good explanation on this behaviour don’t hesitate to post a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2009/08/26/the-value-provided-for-the-report-parameter-is-not-valid-for-its-type/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SSRS and MDX: Detecting Missing Fields</title>
		<link>http://blog.hoegaerden.be/2009/07/06/ssrs-and-mdx-detecting-missing-fields/</link>
		<comments>http://blog.hoegaerden.be/2009/07/06/ssrs-and-mdx-detecting-missing-fields/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 18:15:34 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[MDX]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SSAS]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2009/07/06/ssrs-and-mdx-detecting-missing-fields/</guid>
		<description><![CDATA[For this example I’ll be using the Adventure Works cube running on SQL Server Analysis Services 2008 and Reporting Services 2008.
In case you don’t have the AdventureWorks databases and cubes yet, they’re available at CodePlex.
Scenario
The sales department has asked for a report that displays the number of product items sold during a selected period.&#160; As [...]]]></description>
			<content:encoded><![CDATA[<p>For this example I’ll be using the Adventure Works cube running on SQL Server Analysis Services 2008 and Reporting Services 2008.</p>
<p>In case you don’t have the AdventureWorks databases and cubes yet, they’re available at <a title="SQL Server 2008 sample databases at CodePlex" href="http://msftdbprodsamples.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=18407" target="_blank">CodePlex</a>.</p>
<h2>Scenario</h2>
<p>The sales department has asked for a report that displays the number of product items sold during a selected period.&#160; As the company is active in two different markets, both the internet and reseller numbers should be shown.&#160; The figures need to be grouped by product category, with drilldown to product level through subcategory.</p>
<p>Besides the period filter, it should be possible to filter on product category to limit the number of items shown.</p>
<p>Also, the background of the numeric cells should get a color depending on the value in the cell.&#160; Colors range from red for low sales figures to green for high sale volumes.&#160; The ranges are variable and should thus be configurable using 3 threshold parameters.&#160; Following table shows the ranges as the department has requested them:</p>
<table style="width: 286pt; border-collapse: collapse" border="0" cellspacing="0" cellpadding="0" width="380">
<colgroup>
<col style="width: 188pt; mso-width-source: userset; mso-width-alt: 9142" width="250" />
<col style="width: 98pt; mso-width-source: userset; mso-width-alt: 4754" width="130" /></colgroup>
<tbody>
<tr style="height: 15pt" height="20">
<td style="border-bottom: white 1pt solid; border-left: medium none; width: 188pt; font-family: calibri; background: black; height: 15pt; color: white; font-size: 11pt; border-top: medium none; font-weight: 700; border-right: medium none; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: black none" height="20" width="250">Value X</td>
<td style="border-bottom: white 1pt solid; border-left: medium none; width: 98pt; font-family: calibri; background: black; color: white; font-size: 11pt; border-top: medium none; font-weight: 700; border-right: medium none; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: black none" class="xl65" width="130">Background Color</td>
</tr>
<tr style="height: 15pt" height="20">
<td style="font-family: calibri; background: #376091; height: 15pt; color: white; font-size: 11pt; font-weight: 400; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #376091 none" height="20">X &lt; LowThreshold</td>
<td style="font-family: calibri; background: #376091; color: white; font-size: 11pt; font-weight: 400; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #376091 none" class="xl65">Red</td>
</tr>
<tr style="height: 15pt" height="20">
<td style="font-family: calibri; background: #4f81bd; height: 15pt; color: white; font-size: 11pt; font-weight: 400; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #4f81bd none" height="20">LowThreshold &lt;= MiddleThreshold</td>
<td style="font-family: calibri; background: #4f81bd; color: white; font-size: 11pt; font-weight: 400; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #4f81bd none" class="xl65">Orange</td>
</tr>
<tr style="height: 15pt" height="20">
<td style="border-bottom: medium none; border-left: medium none; font-family: calibri; background: #376091; height: 15pt; color: white; font-size: 11pt; border-top: medium none; font-weight: 400; border-right: medium none; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #376091 none" height="20">MiddleThreshold &lt;= X &lt; HighThreshold</td>
<td style="border-bottom: medium none; border-left: medium none; font-family: calibri; background: #376091; color: white; font-size: 11pt; border-top: medium none; font-weight: 400; border-right: medium none; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #376091 none" class="xl65">Yellow</td>
</tr>
<tr style="height: 15pt" height="20">
<td style="border-bottom: medium none; border-left: medium none; font-family: calibri; background: #4f81bd; height: 15pt; color: white; font-size: 11pt; border-top: medium none; font-weight: 400; border-right: medium none; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #4f81bd none" height="20">HighThreshold &lt; X</td>
<td style="border-bottom: medium none; border-left: medium none; font-family: calibri; background: #4f81bd; color: white; font-size: 11pt; border-top: medium none; font-weight: 400; border-right: medium none; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #4f81bd none" class="xl65">Green</td>
</tr>
</tbody>
</table>
<h2>&#160;</h2>
<h2>Selecting The Data</h2>
<p>At first sight this seems like a fairly simple report.&#160; So you start building your MDX query using the Query Designer:</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/image26.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="MDX Query Designer" border="0" alt="MDX Query Designer" src="http://blog.hoegaerden.be/wp-content/uploads/image-thumb13.png" width="486" height="318" /></a></p>
<p>Two filters have been specified: one of them is a date range and the other is based on product category.</p>
<h2>Visualizing The Data</h2>
<p>Then you drag a <a title="BOL - Understanding the Tablix Data Region" href="http://msdn.microsoft.com/en-us/library/bb677552.aspx" target="_blank">tablix</a> onto the report body and play around with it until you get to the following:</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/image27.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Tablix in design mode" border="0" alt="Tablix in design mode" src="http://blog.hoegaerden.be/wp-content/uploads/image-thumb14.png" width="489" height="61" /></a></p>
<p>This is what it looks like when rendered, all seems to work fine:</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/image28.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Rendered report" border="0" alt="Rendered report" src="http://blog.hoegaerden.be/wp-content/uploads/image-thumb15.png" width="489" height="344" /></a></p>
<p>To get the textbox background coloured based on the thresholds, you’ve produced an expression.&#160; This expression is specified in Textbox Properties &gt; Fill &gt; Fill Color and looks like the following:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&#39;Courier New&#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">=Switch
(
    Fields!Internet_Order_Quantity.Value &lt; Parameters!LowThreshold.Value, <span style="color: #006080">&quot;#ff0e0e&quot;</span>,
    Fields!Internet_Order_Quantity.Value &gt;= Parameters!LowThreshold.Value
        <span style="color: #0000ff">and</span> Fields!Internet_Order_Quantity.Value &lt; Parameters!MiddleThreshold.Value, <span style="color: #006080">&quot;#ff922d&quot;</span>,
    Fields!Internet_Order_Quantity.Value &gt;= Parameters!MiddleThreshold.Value
        <span style="color: #0000ff">and</span> Fields!Internet_Order_Quantity.Value &lt; Parameters!HighThreshold.Value, <span style="color: #006080">&quot;#fff70f&quot;</span>,
    Fields!Internet_Order_Quantity.Value &gt;= Parameters!HighThreshold.Value, <span style="color: #006080">&quot;#5cff21&quot;</span>
)</pre>
</div>
<p>It’s a simple Switch statement using the threshold parameters.</p>
<h3>A Missing Field Issue</h3>
<p>So you deploy your report to the server for the users to test.&#160; All is quiet, until someone starts complaining that the colouring doesn’t always work, for instance when filtering on Components.&#160; Of course, you don’t always believe what the user says and try it out for yourself:</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/image29.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Rendered report with missing field issue" border="0" alt="Rendered report with missing field issue" src="http://blog.hoegaerden.be/wp-content/uploads/image-thumb16.png" width="494" height="151" /></a></p>
<p>Indeed, the background is no longer coloured for the internet sales.&#160; On top of that, the BIDS shows a couple of warnings in its output window:</p>
<blockquote>
<p>[rsMissingFieldInDataSet] The dataset ‘ProductSales’ contains a definition for the Field ‘Internet_Sales_Amount’. This field is missing from the returned result set from the data source.</p>
<p>[rsErrorReadingDataSetField] The dataset ‘ProductSales’ contains a definition for the Field ‘Internet_Sales_Amount’. The data extension returned an error during reading the field. There is no data for the field at position 4.</p>
</blockquote>
<p>Hang on, but I am selecting the field in my dataset, how can it be missing?&#160; Except, this is MDX and OLAP, not SQL and OLTP.&#160; By default, the MDX Query Designer uses NON EMPTY in the SELECT statement.&#160; This means that the rows where there are no values for the selected measures will not be contained in the result set.&#160; It also means that the complete measure will be omitted in the case that there are no values for it in any of the rows, which is the reason for our problem.</p>
<p>You could choose to not use NON EMPTY in the query.&#160; To achieve this using the designer, right-click in the results pane and click the Include Empty Cells item.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="MDX Query Designer result pane popup menu" border="0" alt="MDX Query Designer result pane popup menu" src="http://blog.hoegaerden.be/wp-content/uploads/image30.png" width="233" height="176" /></p>
<p>Keep in mind that this will result in more rows in your result set because you’re now selecting all the empty measure cells as well.&#160; Depending on your report requirements this may not be the desired effect.&#160; On the other hand, it could be exactly what you want.&#160; If our sales department had asked that the report should always show all products, even when there are no sales for the period, then we’d need to query the cube in this way.</p>
<p>For the sake of the example (and to save some trees in case the sales department is going to print the report <img src='http://blog.hoegaerden.be/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ) we will not choose this option.</p>
<h4>Attempt to fix #1</h4>
<p>As the field does not always exist, you decide that it’s a good idea to test for its existence.&#160; A field in a resultset has an IsMissing property which serves that purpose.&#160; So you adapt your expression to the following:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&#39;Courier New&#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">=IIF(Fields!Internet_Order_Quantity.IsMissing, <span style="color: #0000ff">Nothing</span>,
    Switch
    (
        Fields!Internet_Order_Quantity.Value &lt; Parameters!LowThreshold.Value, <span style="color: #006080">&quot;#ff0e0e&quot;</span>,
        Fields!Internet_Order_Quantity.Value &gt;= Parameters!LowThreshold.Value
            <span style="color: #0000ff">and</span> Fields!Internet_Order_Quantity.Value &lt; Parameters!MiddleThreshold.Value, <span style="color: #006080">&quot;#ff922d&quot;</span>,
        Fields!Internet_Order_Quantity.Value &gt;= Parameters!MiddleThreshold.Value
            <span style="color: #0000ff">and</span> Fields!Internet_Order_Quantity.Value &lt; Parameters!HighThreshold.Value, <span style="color: #006080">&quot;#fff70f&quot;</span>,
        Fields!Internet_Order_Quantity.Value &gt;= Parameters!HighThreshold.Value, <span style="color: #006080">&quot;#5cff21&quot;</span>
    )
)</pre>
</div>
<p>However, when filtering on Components the same problem still occurs.&#160; How can this be?&#160; Expressions in SSRS are built using Visual Basic where expressions are evaluated completely.&#160; In our case both the True and the False part of the IIF function are evaluated even when it will always be true.</p>
<p>On to another attempt to get this working.</p>
<h4>(Attempt to) fix #2</h4>
<p>The previous fix attempt has shown that it’s not possible to use an expression for the field validity test.&#160; At least, not in the way we’ve tried until now.&#160; Let’s try using custom code.</p>
<p><a title="BOL - Using Custom Code References in Expressions (Reporting Services)" href="http://msdn.microsoft.com/en-us/library/ms155798.aspx" target="_blank">Custom code</a> can be added to a report through the Code page in the Report Properties dialog box (accessible through the menu Report &gt; Report Properties… or by right-clicking the report’s yellow background).</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Report Properties &gt; Code dialog box" border="0" alt="Report Properties &gt; Code dialog box" src="http://blog.hoegaerden.be/wp-content/uploads/image31.png" width="481" height="399" /></p>
<p>Let’s start with a small extra requirement.&#160; When a measure is not present in a row, such as the Internet Order Quantity for the products in the Components category, the report should display a zero instead of blank space.&#160; To get this done we again need to test on whether or not the field exists in the result set.</p>
<p>The following Visual Basic function accepts a Field object and returns the value of the field when the field exists or zero when the field does not exist.</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&#39;Courier New&#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">'returns the field's value or zero if the field does not exist</span>
<span style="color: #0000ff">Public</span> <span style="color: #0000ff">Function</span> GetValue(field <span style="color: #0000ff">as</span> Field) <span style="color: #0000ff">as</span> <span style="color: #0000ff">Long</span>
  <span style="color: #0000ff">If</span> (field.IsMissing) <span style="color: #0000ff">Then</span>
    <span style="color: #0000ff">Return</span> 0
  <span style="color: #0000ff">ElseIf</span> (IsNothing(field.Value)) <span style="color: #0000ff">Then</span>
    <span style="color: #0000ff">Return</span> 0
  <span style="color: #0000ff">Else</span>
    <span style="color: #0000ff">Return</span> field.Value
  <span style="color: #0000ff">End</span> <span style="color: #0000ff">If</span>
<span style="color: #0000ff">End</span> Function</pre>
</div>
<p>This function can now be used in an expression anywhere in the report.&#160; Here’s what the expression looks like for the Value of the textbox that shows the Internet Order Quantity:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&#39;Courier New&#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">=Code.GetValue(Fields!Internet_Order_Quantity)</pre>
</div>
<p>The same expression is used for the textboxes that display the sum values:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&#39;Courier New&#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">=Sum(Code.GetValue(Fields!Internet_Order_Quantity))</pre>
</div>
<p><strong></strong></p>
<p><strong>Attention:</strong> the function calls above are passing the actual Field object, not the Value property of the field, so not Fields!Internet_Order_Quantity.Value.</p>
<p>So, on to getting our coloring working as required.&#160; For this we need a function that returns the right color for the given amount.&#160; Something like this:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&#39;Courier New&#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">Public</span> <span style="color: #0000ff">Const</span> ColorLow <span style="color: #0000ff">As</span> <span style="color: #0000ff">String</span> = <span style="color: #006080">&quot;#ff0e0e&quot;</span>      <span style="color: #008000">'red</span>
<span style="color: #0000ff">Public</span> <span style="color: #0000ff">Const</span> ColorLowMid <span style="color: #0000ff">As</span> <span style="color: #0000ff">String</span> = <span style="color: #006080">&quot;#ff922d&quot;</span>   <span style="color: #008000">'orange</span>
<span style="color: #0000ff">Public</span> <span style="color: #0000ff">Const</span> ColorMidHigh <span style="color: #0000ff">As</span> <span style="color: #0000ff">String</span> = <span style="color: #006080">&quot;#fff70f&quot;</span>  <span style="color: #008000">'yellow</span>
<span style="color: #0000ff">Public</span> <span style="color: #0000ff">Const</span> ColorHigh <span style="color: #0000ff">As</span> <span style="color: #0000ff">String</span> = <span style="color: #006080">&quot;#5cff21&quot;</span>     <span style="color: #008000">'green</span>

<span style="color: #0000ff">Public</span> <span style="color: #0000ff">Function</span> GetColor(field <span style="color: #0000ff">as</span> Field, low <span style="color: #0000ff">as</span> <span style="color: #0000ff">Integer</span>, mid <span style="color: #0000ff">as</span> <span style="color: #0000ff">Integer</span>, high <span style="color: #0000ff">as</span> <span style="color: #0000ff">Integer</span>) <span style="color: #0000ff">as</span> <span style="color: #0000ff">String</span>
  <span style="color: #0000ff">If</span> (field.IsMissing) <span style="color: #0000ff">Then</span>
    <span style="color: #0000ff">Return</span> ColorLow
  <span style="color: #0000ff">ElseIf</span> (IsNothing(field.Value)) <span style="color: #0000ff">Then</span>
    <span style="color: #0000ff">Return</span> ColorLow
  <span style="color: #0000ff">Else</span>
    <span style="color: #0000ff">Select</span> <span style="color: #0000ff">Case</span> field.Value
      <span style="color: #0000ff">Case</span> <span style="color: #0000ff">Is</span> &lt; low
        <span style="color: #0000ff">Return</span> ColorLow
      <span style="color: #0000ff">Case</span> <span style="color: #0000ff">Is</span> &lt; mid
        <span style="color: #0000ff">Return</span> ColorLowMid
      <span style="color: #0000ff">Case</span> <span style="color: #0000ff">Is</span> &lt; high
        <span style="color: #0000ff">Return</span> ColorMidHigh
      <span style="color: #0000ff">Case</span> <span style="color: #0000ff">Is</span> &gt;= high
        <span style="color: #0000ff">Return</span> ColorHigh
    <span style="color: #0000ff">End</span> <span style="color: #0000ff">Select</span>
  <span style="color: #0000ff">End</span> <span style="color: #0000ff">If</span>
<span style="color: #0000ff">End</span> Function</pre>
</div>
<p>This function accepts a field plus the three threshold values.&#160; Depending on the value of the field and the thresholds, the expected color string is returned.&#160; The red color is returned as well when the field does not exist.</p>
<p>As a good coding practice I’ve created constants for the color strings.&#160; This method allows you to define constants that are available in the whole report – could be interesting if the same colors are used in different parts of a report for instance.</p>
<p>This is the expression used for the BackgroundColor property of the TextBox:</p>
<div>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas,&#39;Courier New&#39;,courier,monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">=Code.GetColor(Fields!Internet_Order_Quantity,
    Parameters!LowThreshold.Value,
    Parameters!MiddleThreshold.Value,
    Parameters!HighThreshold.Value)</pre>
</div>
<p>Again the actual Field object gets passed as first parameter, not just the value.</p>
<p>If we now run the report with a filter on Components, the warnings will still appear in the Output window, but the report will function as expected as the following screenshot shows.&#160; (No Photoshop was used in the making of this screenshot.)&#160; Instead of empty cells the report shows zeroes and the background is coloured even when there are no sales.</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/image32.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Rendered report - fully functional" border="0" alt="Rendered report - fully functional" src="http://blog.hoegaerden.be/wp-content/uploads/image-thumb17.png" width="496" height="395" /></a></p>
<p>Extra info can be found in <a title="BOL - Using Dataset Fields Collection References in Expressions (Reporting Services)" href="http://msdn.microsoft.com/en-us/library/cc281297.aspx" target="_blank">the MSDN page about Using Dataset Field Collection References in Expressions</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2009/07/06/ssrs-and-mdx-detecting-missing-fields/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Is it 32 or 64?</title>
		<link>http://blog.hoegaerden.be/2009/05/01/is-it-32-or-64/</link>
		<comments>http://blog.hoegaerden.be/2009/05/01/is-it-32-or-64/#comments</comments>
		<pubDate>Fri, 01 May 2009 17:16:25 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[ODBC]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2009/05/01/is-it-32-or-64/</guid>
		<description><![CDATA[That’s a question that you should always keep in mind when working on a 64-bit machine.&#160; In case you’re wondering why I’ll tell you a little story.
On a server not so long ago the operating system was Windows Server 2008 64-bit.&#160; The database system was SQL Server 2008, 64-bit as well.
That server needed to be [...]]]></description>
			<content:encoded><![CDATA[<p>That’s a question that you should always keep in mind when working on a 64-bit machine.&#160; In case you’re wondering why I’ll tell you a little story.</p>
<p>On a server not so long ago the operating system was Windows Server 2008 64-bit.&#160; The database system was SQL Server 2008, 64-bit as well.</p>
<p>That server needed to be able to connect to a DB2 database on another server.&#160; For that purpose someone installed the IBM ODBC 9.5 driver, 32-bit.&#160; As usual when someone asks for connectivity to that DB2 server, the batch script containing some typical DB2 commands was executed.&#160; What this script does is create a couple of ODBC System DSNs.&#160; The person that installed the driver showed that all was working fine because using some command-line tool he was able to connect to the databases.</p>
<p>However, when I opened the ODBC Data Source Administrator through Administrative Tools &gt; Data Sources (ODBC), it didn’t show me any System DSNs and when I clicked the Add… button it didn’t show me any DB2 drivers either.&#160; So it seemed that something went wrong.&#160; Or not?</p>
<p>What I needed to be able to do was to connect from Reporting Services to the DB2 database.&#160; So as next test I decided to create a small report directly on the server (BIDS was installed).&#160; And all went fine, I was able to create a data source connecting to DB2 and dataset querying data from the DB2 database.</p>
<p>Then I decided to deploy the report and run it through the Report Manager.&#160; Deployment went fine but when I ran the report it could not connect to DB2.&#160; Hmm, is it working now or not?</p>
<p>I was fairly convinced that it had something to do with the fact that the ODBC driver was 32-bit.&#160; The Business Intelligence Development Studio is 32-bit, that’s why it worked fine using the 32-bit ODBC driver.&#160; But the Report Server is 64-bit, that’s why it couldn’t connect to DB2 using the 32-bit driver.</p>
<p>But why wasn’t the ODBC DSN showing up?&#160; After all, it must exist because the BIDS showed me the list of DSNs that were created.</p>
<p>And then I found the answer, as usual, on the internet.&#160; And it was fairly logical but sometimes you just don’t think of it.&#160; The ODBC Administrator that you launch from the Start &gt; Administrative Tools menu on a 64-bit server is the 64-bit version of the tool.&#160; And that 64-bit version only shows DSNs using 64-bit ODBC drivers.&#160; To get the 32-bit version of the ODBC Administrator you need to launch it manually through Explorer.</p>
<p>And now you may be wondering where on <span style="text-decoration: line-through">earth</span> disk you’re supposed to find that 32-bit version.&#160; Here’s the answer:</p>
<ul>
<li>The 32-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\SysWoW64 folder. </li>
<li>The 64-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\System32 folder. </li>
</ul>
<p>And indeed, that version of the tool showed me the DSNs and the DB2 driver.</p>
<p>(Why they didn’t rename the 64-bit version to odbcad<strong>64</strong>.exe – after all, that is what the 32 in the filename means – remains a mystery to me.)</p>
<p><strong>Sidenote</strong>: there appears to be an issue with this tool where both the 32 and 64-bit version of the tool show both the 32 and 64-bit DSNs.&#160; My server didn’t have this issue but it may be interesting to keep it in mind.&#160; More details about that issue in <a title="The 32-bit version of the ODBC Administrator tool and the 64-bit version of the ODBC Administrator tool display both the 32-bit user DSNs and the 64-bit user DSNs in a 64-bit version of the Windows operating system" href="http://support.microsoft.com/kb/942976" target="_blank">this Microsoft Support article</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2009/05/01/is-it-32-or-64/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS 2005 from SSMS 2008? No.</title>
		<link>http://blog.hoegaerden.be/2009/02/08/ssis-2005-from-ssms-2008-no/</link>
		<comments>http://blog.hoegaerden.be/2009/02/08/ssis-2005-from-ssms-2008-no/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 22:09:27 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Management Studio]]></category>
		<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[SSMS]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2009/02/08/ssis-2005-from-ssms-2008-no/</guid>
		<description><![CDATA[Having trouble connecting to your 2005 Integration Services using Management Studio 2008?  Even when you only have SQL Server Integration Services running, and not version 10.0?

To make it even better, have you noticed that SQL Server Integration Services 10.0 will start up when you connect to it from SSMS 2008?
Well, that&#8217;s by design.  SSMS 2008 [...]]]></description>
			<content:encoded><![CDATA[<p>Having trouble connecting to your 2005 Integration Services using Management Studio 2008?  Even when you only have SQL Server Integration Services running, and not version 10.0?</p>
<p><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" src="http://blog.hoegaerden.be/wp-content/uploads/image8.png" border="0" alt="Integration Services" width="457" height="40" /></p>
<p>To make it even better, have you noticed that SQL Server Integration Services 10.0 will start up when you connect to it from SSMS 2008?</p>
<p>Well, that&#8217;s by design.  SSMS 2008 can only connect to SSIS 2008.  And SSMS 2005 can only connect to SSIS 2005.  So don&#8217;t go uninstalling the 2005 Management Studio to save some space if you use Integration Services 2005!</p>
<p>There&#8217;s some (limited) info on <a title="SSMS 2008 RTM is unable to connect to SSIS 2005 SP2" href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=363010" target="_blank">Microsoft</a> <a title="Can't connect to SSIS 2005 from SSMS CTP5" href="http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=315076" target="_blank">Connect</a> and on <a title="SSMS 2008 can't connect to SSIS 2005" href="http://www.sqlservercentral.com/Forums/Topic560372-391-1.aspx" target="_blank">SQL Server Central</a>.</p>
<p><strong>Update</strong>: when trying to use SSMS 2008 to connect to SSRS 2005, an error coming from the Report Server WMI provider will show up complaining about a couple of invalid namespaces (Microsoft.SqlServer.Management.UI.RSClient and System.Management).  It has been reported as a <a title="SQL 2008 Management Studio and SQL 2005 Reporting Services" href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=361680&amp;wa=wsignin1.0" target="_blank">bug on Microsoft Connect</a>.  Microsoft&#8217;s feedback is that the issue is caused by a breaking change in the WMI namespace and that it won&#8217;t be fixed.</p>
<p>So there you go, neither Reporting Services nor Integration Services 2005 can be connected to using Management Studio 2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2009/02/08/ssis-2005-from-ssms-2008-no/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DIY: Alternative Reporting Services client</title>
		<link>http://blog.hoegaerden.be/2008/08/03/diy-alternative-reporting-services-client/</link>
		<comments>http://blog.hoegaerden.be/2008/08/03/diy-alternative-reporting-services-client/#comments</comments>
		<pubDate>Sun, 03 Aug 2008 13:50:03 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2008/08/03/diy-alternative-reporting-services-client/</guid>
		<description><![CDATA[The other day I was looking for an alternative Reporting Services client, as an extra client besides the web-based Report Manager. As I couldn&#8217;t really find one I thought &#8220;how difficult could it be to write one myself?&#8221;.
And indeed, with the ReportViewer control in Visual Studio 2005 it&#8217;s really no big deal. All you need [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was looking for an alternative Reporting Services client, as an extra client besides the web-based Report Manager. As I couldn&#8217;t really find one I thought &#8220;how difficult could it be to write one myself?&#8221;.</p>
<p>And indeed, with the ReportViewer control in Visual Studio 2005 it&#8217;s really no big deal. All you need to do is drag the control onto a form, tell it that you want to load a remote report, configure the ReportServer so that it knows where to look for reports and the ReportPath so that it knows what report to load. Then call the RefreshReport() method to load the report.</p>
<p>When configuring the ReportPath, pay attention to the mandatory leading slash.</p>
<div>
<div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   1:</span> reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   2:</span> reportViewer1.ServerReport.ReportServerUrl = <span style="color: #0000ff;">new</span> Uri(<span style="color: #006080;">"http://localhost/reportserver"</span>);</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   3:</span> reportViewer1.ServerReport.ReportPath = <span style="color: #006080;">"/My Reports/ReportName"</span>;</pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: #f4f4f4;"><span style="color: #606060;">   4:</span> <span style="color: #008000;">// load report</span></pre>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"><span style="color: #606060;">   5:</span> reportViewer1.RefreshReport();</pre>
</div>
</div>
<p>The C# code snippet above is loading a report called ReportName, located on the local report server in a folder called My Reports.</p>
<p><strong>Update: how to browse the reports on the server</strong></p>
<p>Microsoft has provided an interesting sample called RSExplorer as part of the <a href="http://www.codeplex.com/SqlServerSamples/Release/ProjectReleases.aspx?ReleaseId=4000" target="_blank">SQL Server samples, located at CodePlex</a>.  Once you&#8217;ve installed the samples you can find RSExplorer in C:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Application Samples\RSExplorer Sample\, if you chose to install to the default folder.</p>
<p>The sample shows how to use the Reporting Services web service to populate a WinForms ListView with a list of folders and reports, and even how to do some basic management tasks like creating a folder or editing a report description.</p>
<p>When you double-click a report it will open in a popup window.  What I do find funny in this sample is that the popup window, called ReportViewer, does not use the ReportViewer control.  It uses a WebBrowser control  instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2008/08/03/diy-alternative-reporting-services-client/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005 Reporting Services: the black background issue</title>
		<link>http://blog.hoegaerden.be/2008/07/27/sql-server-2005-reporting-services-the-black-background-issue/</link>
		<comments>http://blog.hoegaerden.be/2008/07/27/sql-server-2005-reporting-services-the-black-background-issue/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 10:12:16 +0000</pubDate>
		<dc:creator>Valentino Vranken</dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://blog.hoegaerden.be/2008/07/27/sql-server-2005-reporting-services-the-black-background-issue/</guid>
		<description><![CDATA[Recently I came across a bug that was introduced in the Reporting Services part of SQL Server 2005 SP2.  When previewing the &#8220;Print Layout&#8221; of the report it would show like this:

The by default Transparent background would show as black instead of white.  Obviously this is not very convenient, especially when the text [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I came across a bug that was introduced in the Reporting Services part of SQL Server 2005 SP2.  When previewing the &#8220;Print Layout&#8221; of the report it would show like this:</p>
<p><a href="http://blog.hoegaerden.be/wp-content/uploads/ssrs-preview-printlayout-bug.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://blog.hoegaerden.be/wp-content/uploads/ssrs-preview-printlayout-bug-thumb.png" border="0" alt="SSRS_preview_printlayout_bug" width="244" height="114" /></a></p>
<p>The by default Transparent background would show as black instead of white.  Obviously this is not very convenient, especially when the text is also black.</p>
<p>Luckily Microsoft was already aware of this issue, its KB is located <a title="http://support.microsoft.com/kb/935436" href="http://support.microsoft.com/kb/935436">here</a>.</p>
<p>I managed to solve the problem by installing Cumulative Update 1 (build 3161), which can be requested for download through the following Microsoft page: <a title="http://support.microsoft.com/kb/935356/en-us" href="http://support.microsoft.com/kb/935356/en-us">http://support.microsoft.com/kb/935356/en-us</a>.</p>
<p>If you don&#8217;t like installing CUs, you could wait until SP3 ships in Q3 this year (this info comes from several sources, just do a search on &#8220;sql server 2005 SP3&#8243;).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hoegaerden.be/2008/07/27/sql-server-2005-reporting-services-the-black-background-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
