SQL Server 2000 Reporting Services: 怎样根据用户的语言偏好显示本地化的信息

2016-01-29 12:59 19 1 收藏

SQL Server 2000 Reporting Services: 怎样根据用户的语言偏好显示本地化的信息,SQL Server 2000 Reporting Services: 怎样根据用户的语言偏好显示本地化的信息

【 tulaoshi.com - ASP.NET 】

Microsoft的Reporting Servcies发布以来,由于其简单易用,功能强大,越来越多的用户选择它来做为报表解决方案。在当今国际化的大趋势下,很多用户在使用Reporting Servcies的时候会遇到一个难题,那就是怎样根据用户的语言偏好显示本地化的信息,比如为中国的用户显示中文的报表标题,为美国的用户显示英文的报表标题;还有如为不同国家的用户显示不同的货币符号等。本文提供了解决这个问题的两个方法. 方法1: Let’s suppose you want to display column names for different users (for example, for Chinese users, display “姓名”; for other users, display “Name”,), you may use expressions to do so as follows: =IIF( User!Language = "zh-CN","姓名","Name") User!Language is a global variable in Reporting Services which will return the user’s language, for English users, it will return “en-US”; for Chinese users, it will return “zh-CN”. For more information regarding User!Language, please refer to MSDN. 方法2: A more flexible but complex way to do so is to use custom assembly in your report. That is, store the localized string in external storage such as SQL Server database or XML files, then write a custom assembly to retrieve the localized string from the external storage based on user’s language, and then call this assembly in your report. The detailed steps are: 1. Create a table to store the localized string: use Northwindgocreate table localizationTbl(sourceStr nvarchar(20), language nvarchar(10), destStr nvarchar(20))goinsert into localizationTbl values(N'Name',N'zh-CN',N'姓名')insert into localizationTbl values(N'Name',N'en-US',N'Name')go 2. Create the custom assembly. Launch Visual Studio .NET 2003, create a Class Library project, and add a static method to retrieve the localized string from the database: using System;using System.Data;using System.Data.SqlClient;using System.Security;using System.Security.Permissions; namespace getLocalString{ public class Class1 { public static string GetLocalizedString(string language, string sourceStr) { SqlClientPermission permission = new SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted); permission.Assert(); SqlConnection conn = new SqlConnection(); conn.ConnectionString = @"server = serverName;database=northwind;uid=sa;pwd=xxxx;"; SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select destStr from localizationTbl where language = '" + language + "' and sourceStr = '" + sourceStr + "'"; cmd.CommandType = CommandType.Text; cmd.Connection = conn; conn.Open(); return cmd.ExecuteScalar().ToString(); } }} 3. Build the project, and then deploy the DLL file to Reporting Services. To deploy the DLL file, copy it from your build location to the report server bin folder and the Report Designer folder. The default location of the bin folder for the report server is C:Program FilesMicrosoft SQL ServerMSSQLReporting ServicesReportServerbin. The default location of the Report Designer is C:Program FilesMicrosoft SQL Server80ToolsReport Designer. 4. By default, the custom assembly doesn’t have permission to run in Reporting Services, you need to modify the configuration files of Report Designer and report server to grant it the FullTrust Permission. The configuration file for report server is C:Program FilesMicrosoft SQL ServerMSSQLReporting ServicesReportServerrssrvpolicy.config. The configuration file of report designer is C:Program FilesMicrosoft SQL Server80ToolsReport Designerrspreviewpolicy.config. You need to add a code group for your custom assembly similar as follows (please modify the value for the URL attribute based on your DLL file name): For more information regarding code access security for Reporting Serv

来源:http://www.tulaoshi.com/n/20160129/1488452.html

延伸阅读
标签: SQLServer
  SQL Server 2000的安全配置在进行SQL Server 2000数据库的安全配置之前,首先你必须对操作系统进行安全配置,保证你的操作系统处于安全状态。然后对你要使用的操作数据库软件(程序)进行必要的安全审核,比如对ASP、PHP等脚本,这是很多基于数据库的WEB应用常出现的安全隐患,对于脚本主要是一个过滤问题,需要过滤一些类似 , ‘ ...
标签: SQLServer
Sybase中的用户分为两种:SQL服务器用户(登录帐号)和数据库用户。  安装完SQL服务器后,系统自动建立一个SQL服务器用户sa,口令为空,即系统管理员,他对整个系统有操作权,其他用户均由系统管理员建立。    在SQL Server中有三种特殊的用户:系统管理员、用户数据库所有者(建立相应数据库的数据库用户)DBO...
1.3.4 Profiler SQL Server Profiler 是一个图形化的管理工具用于监督记录和检查SQL Server 数据库的使用情况对系统管理员来说它是一个监视用户活动的间谍 1.3.5 Client Network Utility SQL Server Client Network Utility 用于配置客户端的连接测定网络库的版本信息以及设定本地数据库的相关选项 1.3.6 Server Netwo...
数据库操作现在是项目开发的根本,学习Java首先应该学会怎么样连接数据库,用Java连接数据库可不像用Delphi这类工具那样设几个属性就OK,说简单也简单,说复杂,其实也挺复杂的,而且很麻烦,如果是初学,根本不能保证第一次就连接成功,下面以SQL Server 2000为例,说说Java连接数据库的基本方法,也记录一下心得。 1、下载SQL Server 2000 ...
标签: SQLServer
SQL Server 2000的安全配置在进行SQL Server 2000数据库的安全配置之前,首先你必须对操作系统进行安全配置,保证你的操作系统处于安全状态。然后对你要使用的操作数据库软件(程序)进行必要的安全审核,比如对ASP、PHP等脚本,这是很多基于数据库的WEB应用常出现的安全隐患,对于脚本主要是一个过滤问题,需要过滤一些类...

经验教程

716

收藏

72
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部