原文 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.

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

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

    实验环境:服务器  Windows Server  2008 R2 Standard 64bit                   数据库  SQL SERVER 2008 R2 Standard ...

  2. 实现SQL Server 2008 Reporting Services匿名访问报表有两种方法

    一.通过修改SQL Server 2008的配置文件,去掉Windows的验证. 1.首先我们找到SQL安装目录下的两个Web.config配置文件,默认安装目录分别是(C:\Program File ...

  3. Set up JBPM5.4 Final Installer to use MS SQL Server 2008 using JTDS(转)

    [-] A What I Am Going To Do B The Setup Steps C Lets Install it   A. What I Am Going To Do B. The Se ...

  4. MS SQL SERVER 2008 使用OBJECT_ID判断临时表是否存在

    MS SQL SERVER 2008 使用OBJECT_ID判断临时表是否存在 我们在写sql 脚本的时候经常会用到临时表,有时间也需要根据临时表是否存在做一些逻辑处理.还好sql server已经集 ...

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

    原文:[翻译]初识SQL Server 2005 Reporting Services Part 3 这是关于SSRS文章中四部分的第三部分.Part 1提供了一个创建基本报表的递阶教程.Part 2 ...

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

    原文:[翻译]初识SQL Server 2005 Reporting Services Part 4 这一篇是关于SQL Server 2005 Reporting Services四篇文章中最后一篇 ...

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

    原文:[翻译]初识SQL Server 2005 Reporting Services Part 2 在Part 1文章中我们对SQL Server Reporting Services 2005(S ...

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

    原文:[翻译]初识SQL Server 2005 Reporting Services Part 1 构建和部署基本报表 如果曾经存在一项工作使得“真正的”开发者给他的上司泡蘑菇,那就是构建报表.毕竟 ...

  9. 使用SQL Database Migration Wizard把SQL Server 2008迁移到Windows Azure SQL Database

    本篇体验使用SQL Database Migration Wizard(SQLAzureMW)将SQL Server 2008数据库迁移到 Azure SQL Database.当然,SQLAzure ...

随机推荐

  1. ASP.NET 应用程序生命周期

    1.请求到达IIS服务器,IIS根据文件后缀找到对应的ISAPI(Internet Server API)扩展来处理,这个配置可在网站属性里的“根目录”选项卡中的“配置”里看到.可以看到,ashx.a ...

  2. jdk和jre是什么?都有什么用?

    大家肯定在安装JDK的时候会有选择是否安装单独的jre,一般都会一起安装,我也建议大家这样做.由于这样更能帮助大家弄清楚它们的差别: Jre   是java   runtime   environme ...

  3. TimesTen更改CacheGroup管理用户ORACLE结束和TT结束password【TimesTen操作和维修基地】

    password管理一直操作的一部分的安全管理和维护.CacheGroup管理用户password虽然并不复杂变化.然而,这是用于生产,改不好比较easy导致失败.简介点击这里CacheGroup管理 ...

  4. 深度this指针

    深入探讨this指针   为了写这篇文章.准备了好长时间,翻遍了箱底的书籍.可是如今还是不敢放开手来写,战战兢兢. 不是操心自己写错.而是唯恐自己错误误导别人.同一时候也希望这篇文章能给你一点收获.既 ...

  5. jQuery照片伸缩效应,这不是一个简单的图像缩放,它不影响其它元素的布局

    之前在网上看到这样的效果,但我没有收藏夹网址,后来被我不知道如何来实现这种效果. 如今,互联网已收集有关专门.真是功夫不负有心人,被我发现. 我也努力过自己尝试着写: 但仅仅是单纯的图片放大.并且还影 ...

  6. 皮尔逊相似度计算的例子(R语言)

    编译最近的协同过滤算法皮尔逊相似度计算.下顺便研究R简单使用的语言.概率统计知识. 一.概率论和统计学概念复习 1)期望值(Expected Value) 由于这里每一个数都是等概率的.所以就当做是数 ...

  7. 读书时间《JavaScript高级程序设计》六:事件

    Javascript与HTML之间的交互是通过事件实现的. 1. 事件流 事件流描述的是从页面中接收事件的顺序. <!DOCTYPE html> <html> <head ...

  8. jqm视频播放器,html5视频播放器,html5音乐播放器,html5媒体播放器,video开展demo,html5视频播放演示示例,html5移动视频播放器

    最近看到很多有用的论坛html5视频播放的发展,音乐播放功能,大多数都在寻找答案.所以,我在这里做一个demo.对于大家互相学习.html5开发越来越流行,至于这也是一个不可缺少的一部分的视频. 如何 ...

  9. TCP与UDP的侵略性

    HTTP必须执行在TCP上吗?SSL必须执行在TCP上吗?...实际上HTTP并没有规定一定要执行在TCP上,甚至FTP也不一定要执行在TCP上!HTTP或者FTP仅仅是说底层信道要保证数据的按序传输 ...

  10. java使用Base64编码和解码的图像文件

    1.编码和解码下面的代码示例看: import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import j ...