Dim CRrpt As New ReportDocument()
Dim CRrptTDASub1 As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
Case "LH Turbidity Data Analysis Sheet 2 - Page 9"
strFilename = gstrRptLocation & "rptLHWaterTreatmentPlant-NewPage9.rpt"
CRrpt.Load(strFilename)
Call MainLogin2()
CRrpt.SetParameterValue(0, gintRptMonth)
CRrpt.SetParameterValue(1, gintRptYear)
CRrpt.SetParameterValue(2, mstrMonthYearText)
' ******** SUB REPORT ********
CRrptTDASub2 = CRrpt.OpenSubreport("rptLHWaterTreatmentPlant-NewPage9A")
Dim myTableLogOnInfoA As TableLogOnInfo
' ******** problem is here ********
è è myTableLogOnInfoA = New TableLogOnInfo(CRrptTDASub1.Database.Tables.Item(1).LogOnInfo)
Dim myConnectionInfoA As New ConnectionInfo
myConnectionInfoA.ServerName = gSQLServer
myConnectionInfoA.UserID = gSQLUser
myConnectionInfoA.Password = gSQLPW
myTableLogOnInfoA.ConnectionInfo = myConnectionInfoA
CRrptTDASub1.Database.Tables.Item(1).ApplyLogOnInfo(myTableLogOnInfoA)
CRrptTDASub1.SetParameterValue(0, gintRptMonth)
CRrptTDASub1.SetParameterValue(1, gintRptYear)
CRrptTDASub1.SetParameterValue(2, mstrMonthYearText)
CRViewer1.ReportSource = CRrpt
CRViewer1.ShowFirstPage()
System.Windows.Forms.Cursor.Current =
System.Windows.Forms.Cursors.Default
'End of Page 9 Code
Private Sub MainLogin2()
Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crSubreportObject As SubreportObject
Dim crReportDocument As New ReportDocument
Dim crSubreportDocument As ReportDocument
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
Dim myTableLogOnInfo As TableLogOnInfo
Dim myConnectionInfo As ConnectionInfo
myConnectionInfo = New ConnectionInfo()
With myConnectionInfo
.DatabaseName = gSQLDatabase
.ServerName = gSQLServer
.UserID = gSQLUser
.Password = gSQLPW
End With
crDatabase = CRrpt.Database
crTables = crDatabase.Tables
For Each crTable In crTables
myTableLogOnInfo = crTable.LogOnInfo
myTableLogOnInfo.ConnectionInfo = myConnectionInfo
crTable.ApplyLogOnInfo(myTableLogOnInfo)
Next
crSections = CRrpt.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject Then
crSubreportObject = CType(crReportObject, SubreportObject)
crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
crDatabase = crSubreportDocument.Database
crTables = crDatabase.Tables
For Each crTable In crTables
With myConnectionInfo
.DatabaseName = gSQLDatabase
.ServerName = gSQLServer
.UserID = gSQLUser
.Password = gSQLPW
End With
myTableLogOnInfo = crTable.LogOnInfo
myTableLogOnInfo.ConnectionInfo = myConnectionInfo
crTable.ApplyLogOnInfo(myTableLogOnInfo)
Next
End If
Next
Next
End Sub