Display Database Image using MS SQL Server 2008 Reporting Services

本文涉及的产品
云数据库 RDS SQL Server,基础系列 2核4GB
RDS SQL Server Serverless,2-4RCU 50GB 3个月
推荐场景:
简介: 原文 Display Database Image using MS SQL Server 2008 Reporting Services With the new release of MS SQL Server 2008 Reporting Services has introduced a ...

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

save image files in sql server using openrowset

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.

dataset for reading and displaying image from sql 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.

SSRS databound image from DB design view table

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

SSRS toolbox image component

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.

SSRS databound image from db image properties

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 image from database using sql reporting services report

 

相关实践学习
使用SQL语句管理索引
本次实验主要介绍如何在RDS-SQLServer数据库中,使用SQL语句管理索引。
SQL Server on Linux入门教程
SQL Server数据库一直只提供Windows下的版本。2016年微软宣布推出可运行在Linux系统下的SQL Server数据库,该版本目前还是早期预览版本。本课程主要介绍SQLServer On Linux的基本知识。 相关的阿里云产品:云数据库RDS SQL Server版 RDS SQL Server不仅拥有高可用架构和任意时间点的数据恢复功能,强力支撑各种企业应用,同时也包含了微软的License费用,减少额外支出。 了解产品详情: https://www.aliyun.com/product/rds/sqlserver
目录
相关文章
|
2月前
|
安全 关系型数据库 MySQL
openvas报错Warning: Secinfo Database Missing SCAP and/or CERT database missing on OMP server.
openvas报错Warning: Secinfo Database Missing SCAP and/or CERT database missing on OMP server.
|
3月前
|
关系型数据库 MySQL 网络安全
5-10Can't connect to MySQL server on 'sh-cynosl-grp-fcs50xoa.sql.tencentcdb.com' (110)")
5-10Can't connect to MySQL server on 'sh-cynosl-grp-fcs50xoa.sql.tencentcdb.com' (110)")
|
5月前
|
SQL 存储 监控
SQL Server的并行实施如何优化?
【7月更文挑战第23天】SQL Server的并行实施如何优化?
135 13
|
5月前
|
SQL
解锁 SQL Server 2022的时间序列数据功能
【7月更文挑战第14天】要解锁SQL Server 2022的时间序列数据功能,可使用`generate_series`函数生成整数序列,例如:`SELECT value FROM generate_series(1, 10)。此外,`date_bucket`函数能按指定间隔(如周)对日期时间值分组,这些工具结合窗口函数和其他时间日期函数,能高效处理和分析时间序列数据。更多信息请参考官方文档和技术资料。
|
4月前
|
Java 测试技术 容器
从零到英雄:Struts 2 最佳实践——你的Web应用开发超级变身指南!
【8月更文挑战第31天】《Struts 2 最佳实践:从设计到部署的全流程指南》深入介绍如何利用 Struts 2 框架从项目设计到部署的全流程。从初始化配置到采用 MVC 设计模式,再到性能优化与测试,本书详细讲解了如何构建高效、稳定的 Web 应用。通过最佳实践和代码示例,帮助读者掌握 Struts 2 的核心功能,并确保应用的安全性和可维护性。无论是在项目初期还是后期运维,本书都是不可或缺的参考指南。
55 0
|
5月前
|
SQL 存储 网络安全
关系数据库SQLserver 安装 SQL Server
【7月更文挑战第26天】
73 6
|
5月前
|
存储 SQL C++
对比 SQL Server中的VARCHAR(max) 与VARCHAR(n) 数据类型
【7月更文挑战7天】SQL Server 中的 VARCHAR(max) vs VARCHAR(n): - VARCHAR(n) 存储最多 n 个字符(1-8000),适合短文本。 - VARCHAR(max) 可存储约 21 亿个字符,适合大量文本。 - VARCHAR(n) 在处理小数据时性能更好,空间固定。 - VARCHAR(max) 对于大文本更合适,但可能影响性能。 - 选择取决于数据长度预期和业务需求。
469 1
|
5月前
|
SQL Oracle 关系型数据库
MySQL、SQL Server和Oracle数据库安装部署教程
数据库的安装部署教程因不同的数据库管理系统(DBMS)而异,以下将以MySQL、SQL Server和Oracle为例,分别概述其安装部署的基本步骤。请注意,由于软件版本和操作系统的不同,具体步骤可能会有所变化。
388 3
|
5月前
|
SQL 数据库
SQL CREATE DATABASE 语句
【7月更文挑战第18天】SQL CREATE DATABASE 语句。
150 1
|
4月前
|
SQL 安全 Java
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
536 0