Crystal Report Datasource remap

后端 未结 2 407
情歌与酒
情歌与酒 2020-12-11 13:57

I am working with Crystal Reports and MS SQL Server. I need to remap the crystal report to point to a different database on the same SQL Server. Is there an automated way of

2条回答
  •  离开以前
    2020-12-11 14:46

    You can get any of the info from the current report connection info. So if your not changing servers, then set the crystalServer variable to the reports current server.

    '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
    

提交回复
热议问题