Display Database Image using MS SQL Server 2008 Reporting Services

原文 Display Database Image using MS SQL Server 2008 Reporting Services

With the new release of MS SQL Server 2008 Reporting Services has introduced a new feature that will help report developers (Business Intelligence BI professionals) to display images stored in database tables.
Since Microsoft SQL Server Reporting Services is gaining power in covering the requirements of business intelligence developers day by day, it is gaining more acceptance from the BI professionals.

For building a Microsoft Reporting Services solution to display database image or display image from database, we will first create sql database image table and insert images into the sql database for populating table with sample data.
Of course you should either create a new MS Reporting Services solution or open an existing MS Reporting Services solution and add reporting services report to this solution.

 

Prepare SQL Database and Populate with Sample Images in order to use in Reporing Services Report

First of all by executing the below t-sql Create Table command sql database administrators can create the database table in which sql developers will store images or image files in binary format in avarbinary(max) data type column.

CREATE TABLE DBFiles (
 id int IDENTITY(1,1) NOT NULL,
 fname nvarchar(1000) NOT NULL,
 [file] varbinary(max)
)

 

Save Image in SQL Database in Binary Format

After we have created the sql database table to store the image files, now we can begin inserting images into the newly created sql database table.
You can also refer to SQL tutorial Save Image to Database Table in SQL Server for an other example.

INSERT INTO DBFiles(fname, [file])
SELECT 'Reporting-Services-2008-enriched-visualization-gadgets.jpg', * FROM OPENROWSET(
 BULK N'C:\Reporting-Services-2008-enriched-visualization-gadgets.jpg',
 SINGLE_BLOB
) rs;
INSERT INTO DBFiles(fname, [file]) 
SELECT 'what-is-new-with-SQL-Server-2008.jpg', * FROM OPENROWSET(
 BULK N'C:\what-is-new-with-SQL-Server-2008.jpg',
 SINGLE_BLOB
) rs;

You can download the sample image files photos I've taken during TechEd Developers 2007 related withMS SQL Server 2008 and MS SQL Server Reporting Services 2008 from the following links :
Reporting Services 2008 enriched visualization gadgets
What is new with SQL Server 2008

Let's see how images we have inserted into the sql table is seen when we execute a SELECT statement.

SELECT * FROM Files

Now we have created our sample sql table and populate the image table with sample image files.
We can now create our MS SQL Server Reporting Services 2008 report which will display the image files stored in the SQL Server database table.

 

Build SQL Reporting Services DataSet for Sample Report

First of all, we will create a dataset for reading data from SQL Server database image table.
We will use this dataset for databinding to reporting services table control and image control within the table cells for each row in the sql image table.

The sql query for the dataset is : SELECT * FROM DBFiles
This t-sql query will supply the sql data in binary format which we will display using Reporting Services.

 

Design Reporting Services Report in order to Display Database Image

After the dataset of the SQL Reporting Services report is prepared, now we can switch to the design view.
Place a table onto the Design surface of the SSSRS 2008 report.
Then set the DataSetName property of the new Tablix component to the dataset we have created for this sample report.

Then set field properties or the columns of the report design view tablix component as you wish.

Select the Reporting Services image component from the Toolbox and drag and drop into an emptytablix column.

This action will trigger the Reporting Services Image Properties Wizard.
You can later alter the properties of the image cell by a click on the image properties menu item on the context menu of the image cell.

Set the image properties as follows :
1) Set the image source as database, since we are selecting the image in binary format from database using reporting services dataset.
2) When database is chosen as the source of the image, you will select the field name as [file] field of the dataset in the Use this field dropdown list.
3) Also as the last step select the MIME type as image/jpeg (or which is approtiate for your case)

 

Resize Database Image and Size Properties of the SQL Database Image

You can also set the size properties of the database image and image component within the tablixcomponent by displaying the image properties and navigating to the Size tab.
There you can select one of the following size properties for display database images.
Original size
Fit to size
Fit proportional
Clip

I have selected fit proportional option which will resize image to fit inside the item while maintaining the aspect ratio.

 

Display Database Image on a SQL Server Reporting Services Report

After we have finished developing the MS SQL Server 2008 Reporting Services report, if you switch to the preview tab we can see the images stores in sql table on our sample SSRS report.

 

时间: 2024-11-18 09:29:53

Display Database Image using MS SQL Server 2008 Reporting Services的相关文章

report-使用Microsoft SQL Server 2008 Reporting Services制作报表

问题描述 使用Microsoft SQL Server 2008 Reporting Services制作报表 使用Microsoft SQL Server 2008 Reporting Services制作报表,折线图上显示一条平均数,希望在这条线的后面显示这条线的数值怎么实现?要是用显示数据标签的话会每个点都显示太乱了. 解决方案 http://www.microsoft.com/china/sql/2008/prodinfo/reporting.aspx

SQL SERVER 2008 Reporting Services 的一些小问题集合

实验环境:服务器  Windows Server  2008 R2 Standard 64bit                   数据库  SQL SERVER 2008 R2 Standard 64bit 问题1:在SQL Server 2008下,配置了Reporting Services后,在IE里输入http://localhost/Reports/Pages/Folder.aspx从客户端用IE访问后,出现下面错误                                  

微软SQL Server 2000 Reporting Services介绍(四)

server|services|微软 微软SQL Server 2000 Reporting Services介绍(四) [摘要 ] 本文对Reporting Services的一些不太常见的功能进行了分析,最后根据使用情况列举了Reporting Services的一些不足的地方,估计这些不足都会在正式版中解决. [关键字] Reporting Services,.NET Framework. DrillThrough,rdl文件,rds文件 n rdl文件元素 在上一篇文章里简单的分析了rd

[翻译]初识SQL Server 2005 Reporting Services Part 1

原文:[翻译]初识SQL Server 2005 Reporting Services Part 1 构建和部署基本报表 如果曾经存在一项工作使得"真正的"开发者给他的上司泡蘑菇,那就是构建报表.毕竟那并不是真正的开发,更像是制作美化的格式.而且你所使用的构建报表的工具试图提供一个抽象层,这个经常妨碍你对报表的真正掌控.我以前经常听到这些争论.如果这听上去像你曾经在一个水制冷器旁边的对话,那么我请你仔细关注一下SQL Server 2005 Reporting Services(SSR

[翻译]初识SQL Server 2005 Reporting Services Part 2

原文:[翻译]初识SQL Server 2005 Reporting Services Part 2   在Part 1文章中我们对SQL Server Reporting Services 2005(SSRS)有了一个初步的了解.我们分别通过报表向导和报表设计器构建了两个报表.在Part 2我们将以一个SSRS开发者的身份深入查看更多特征信息. 以下是我们要研究的: l 表达式的用法.这些表达式可以让你动态的控制从控件属性到数据绑定的报表的各个方面. l 报表中用到的计算和操作的通用函数. l

[翻译]初识SQL Server 2005 Reporting Services Part 3

原文:[翻译]初识SQL Server 2005 Reporting Services Part 3 这是关于SSRS文章中四部分的第三部分.Part 1提供了一个创建基本报表的递阶教程.Part 2展现了为制作动态报表所用到的SSRS2005的核心特性和功能.这一部分中我们将把注意力转向SSRS中的图表控件. 微软的图表控件其实是Dundas 图标控件的按比例缩小版.不管是不是缩小版,我敢说这个的确非常好用.对好多人来说,他们使用SSRS就是看中了这个控件. 在这篇中我们要创建一个带有图表控件

[翻译]初识SQL Server 2005 Reporting Services Part 4

原文:[翻译]初识SQL Server 2005 Reporting Services Part 4 这一篇是关于SQL Server 2005 Reporting Services四篇文章中最后一篇:     Part 1,提供了创建基本报表的指南   Part 2,介绍了创建动态报表用到的SSRS核心特性和功能   Part 3,完全介绍了嵌入到SSRS中的图表控件   这里,在Part 4,我们把精力放在报表定义语言(RDL)上.RDL的定义在MSDN2给的很好,所以我在引用一下:   "

MS SQL Server 2008安装图集

Microsoft SQL Server 2008 安装图集 见下:

MS SQL Server 2008发布与订阅

本文转载:http://chaoyouzhuo.blog.163.com/blog/static/126376001201173092514498/ 参考文章:http://www.cnblogs.com/gbmf/archive/2009/06/04/1496013.html   如果选择的是"快照发布":则必须在发布服务器需要设置代理时间计划,订阅服务器可以不用设置代理时间计划. 如果选择的是"事务发布":则发布服务器和订阅服务器不需要设置代理时间计划,这样几乎