SQL Reporting Service 2000 部署

SQL Reporting Service 2000 部署

在生产环境部署SQL Reporting Service 2000 报表是比较麻烦的一件事情,往往实施人员到客户生产环境时,没有Visual  Studio的帮助,需要自己手动建立数据源、手动上传一张一张的报表,并且手动设置访问权限。

Reporting Service 提供一个Web Service服务,帮助系统自动完成报表管理工作。
下面我们就来看看如果利用Reporting Service提供的Web Service服务。

1、新建一个项目

2、添加web引用
http://localhost/ReportServer/ReportService.asmx
如果ReportingService不是安装在本机,将localhost改为ReportingService所在计算机的名称或IP。

3、定义一个变量
ReportingService rs = new ReportingService(txtWebService.Text);

4、需要在根目录下创建文件夹
rs.CreateFolder(txtServerPath.Text, "/", null);

5、定义数据源
DataSourceDefinition dsd = new DataSourceDefinition();
dsd.CredentialRetrieval = CredentialRetrievalEnum.Store;
dsd.ConnectString = txtSQLConnectionString.Text;
dsd.Enabled = true;
dsd.EnabledSpecified = true;
dsd.Extension = "SQL";
dsd.ImpersonateUser = false;
dsd.ImpersonateUserSpecified = true;
dsd.Prompt = null;
dsd.UserName = txtUserName.Text;
dsd.Password = txtPassword.Text;
dsd.WindowsCredentials = false;
try
{
    rs.CreateDataSource(txtDataSourceName.Text, "/" + txtServerPath.Text, true, dsd, null);
}
catch (Exception ex)
{
    WirteMsg(ex.Message);
    return;
}

6、将报表文件(*.rdl)读取到byte数组中
FileStream stream = File.OpenRead(file);
byte[] definition = new byte[stream.Length];
stream.Read(definition, 0, (int) stream.Length);
stream.Close();

7、上传报表到服务器
rs.CreateReport(Path.GetFileName(file), "/" + txtServerPath.Text, true, definition, null);

8、对用户授权访问
打开http://localhost/Reports,进入你新建的目录,在属性中,选择安全,再点击“编辑项安全设置”,在这里编辑用户权限,特别:可能需要对IIS用户和
ASPNET或IIS_WPG授权,得看具体情况。

下载源代码 

posted on 2005-12-31 16:08  sdxd.bgl  阅读(759)  评论(0)    收藏  举报

导航