替换报表和所有子报表的数据库连接 [英] Replace a database connection for report and all subreports

查看:14
本文介绍了替换报表和所有子报表的数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以更改报表及其所有子报表的数据源位置,而无需手动打开每个子报表?

Is there is any way to change the datasource location for a report and all of it's subreports without having to open each of them manually?

推荐答案

这是我在运行时设置连接的方式.我从配置位置获取连接信息.

Here is how I set my connections at runtime. I get the connection info from a config location.

        #'SET REPORT CONNECTION INFO
        For i = 0 To rsource.ReportDocument.DataSourceConnections.Count - 1
            rsource.ReportDocument.DataSourceConnections(i).SetConnection(crystalServer, crystalDB, crystalUser, crystalPassword)
        Next

        For i = 0 To rsource.ReportDocument.Subreports.Count - 1
            For x = 0 To rsource.ReportDocument.Subreports(i).DataSourceConnections.Count - 1
                rsource.ReportDocument.OpenSubreport(rsource.ReportDocument.Subreports(i).Name).DataSourceConnections(x).SetConnection(crystalServer, crystalDB, crystalUser, crystalPassword)
            Next
        Next

这篇关于替换报表和所有子报表的数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆