I have used it before but for some reason it doesnt want to work.
Expand|Select|Wrap|Line Numbers
- Dim report As New CrystalDecisions.CrystalReports.Engine.ReportDocument
- Dim connection As IConnectionInfo
- Dim OldServerName As String = [OLD Servername]
- Dim NewServerName As String = [NEW SERVERName]
- Dim NewDatabaseName As String = [New DB]
- Dim OldDatabaseName As String = [OLD DB]
- Dim UserID As String = ""
- Dim Password As String = ""
- report.Load(Application.StartupPath + "\Reports\SCBA_HISTORY_MAINTENANCE_REPORT.rpt")
- 'relac = "{SCBAMASK.SerialNo}=" & Chr(39) & (strEditSCBAMASKSERIAL) & Chr(39)
- 'report.DataDefinition.RecordSelectionFormula = relac
- CrystalReportViewer1.ReportSource = report
- 'Change the servername and database in main report
- For Each connection In report.DataSourceConnections
- report.DataSourceConnections(OldServerName, OldDatabaseName).SetConnection(NewServerName, NewDatabaseName, UserID, Password)
- Next
- 'Change the servername and database in subreports
- For Each subreport In report.Subreports
- For Each connection In subreport.datasourceconnections
- If (String.Compare(connection.ServerName, OldServerName, True) = 0 _
- And String.Compare(connection.DatabaseName, OldDatabaseName, True) = 0) Then
- subreport.DataSourceConnections(OldServerName, OldDatabaseName).SetConnection(NewServerName, NewDatabaseName, UserID, Password)
- End If
- Next
- Next
- CrystalReportViewer1.RefreshReport()
- 'Me.Close()
- 'MsgBox(ex.Message)
- 'CrystalReportViewer1.PrintReport()
But on my pc it changes perfectly.
Its like its not pulling through the Database Name
But when debugging it pulls through the databse name no problems.
Can anyone see something i dont.