Hi, maybe this can help:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource
Private crParameterFields As New ParameterFields
Private crReportDocument As New ReportDocument
Public Sub InitialiseReport(ByVal psReportName As String, ByVal psTitle As
String)
Dim tblCurrent As Table
Dim crSubreportObject As SubreportObject
Dim subRepDoc As New ReportDocument
Dim crDatabase As
CrystalDecisions.CrystalReports.Engine.Database
Dim crTables As Tables
Dim crTable As Table
Dim crSection As Section
Dim crSections As Sections
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crLogOnInfo As TableLogOnInfo
Dim crpConnectionInfo As New
CrystalDecisions.Shared.ConnectionInfo
Dim crpTableLogOnInfo As New
CrystalDecisions.Shared.TableLogOnInfo
crReportDocument.Load(psReportName)
CrystalReportViewer1.ReportSource = crReportDocument
'
' change server for main report
'
With crpConnectionInfo
.ServerName = "yourservername"
.DatabaseName = "yourdatabase"
End With
'if integrated security isn't true
crpConnectionInfo.UserID = "userid"
crpConnectionInfo.Password = "password"
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next
'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind =
ReportObjectKind.SubreportObject Then
'If you find a subreport, typecast the reportobject
to a subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)
'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject. SubreportName)
crDatabase = subRepDoc.Database
crTables = crDatabase.Tables
'Loop through each table and set the connection info
'Pass the connection info to the logoninfo object
then apply the
'logoninfo to the subreport
For Each crTable In crTables
With crpConnectionInfo
.ServerName =
FalProjectFuncties.OphalenConfigWaarde("CrystalRep ort", "Servernaam")
.DatabaseName =
FalProjectFuncties.OphalenConfigWaarde("CrystalRep ort", "Database")
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
Next
End If
Next
Next
End Sub
Hth greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"Agnes" <ag***@dynamictech.com.hk> schreef in bericht
news:#B**************@tk2msftngp13.phx.gbl...
Please help, i had completed over 30-50 reports, now. our client insist to
change the database name.
anyshorcut that I can change the database name in the report without
re-write all of them ??
Thanks in advance