C
Craig G
we have a vb.net app that displays a series of reports
this is all working fine when it is just one report, but if we have a report which contains a subreport then it fails, i assume you need to logon to the subreports also but im not sure how to.
the subreports also require 4 parameter values to be passed to it
any help would be greatly appreciated
Cheers,
Craig
here is the code we use for calling a single report
************************************************************
Private Function fun_ShowReport() As Boolean
Dim obj_Report As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim frm_Viewer As New frmViewReport
Dim crTableLogonInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
Try
crTableLogonInfo = New TableLogOnInfo
crConnectionInfo = New ConnectionInfo
crConnectionInfo.DatabaseName = g_str_Database
crConnectionInfo.ServerName = g_str_Server
crConnectionInfo.UserID = g_str_Username
crConnectionInfo.Password = g_str_Password
crTableLogonInfo.ConnectionInfo = crConnectionInfo
With obj_Report
..Load(m_str_ReportFilename)
For Each crTable In .Database.Tables
crTable.ApplyLogOnInfo(crTableLogonInfo)
Next
..SetParameterValue("@FromDate", txt_StartDate.SetDBValue)
..SetParameterValue("@ToDate", txt_EndDate.SetDBValue)
If m_int_ReportName <> ReportName.Report_UserFeedback Then
..SetParameterValue("@HospitalID", fun_SetNull(clsPharmacyClass.ReportHospital))
..SetParameterValue("@WardID", fun_SetNull(clsPharmacyClass.ReportWard))
End If
Select Case m_int_ReportName
Case ReportName.Report_Intervention
..SetParameterValue("@PatientID", 0)
..SetParameterValue("@PharmacistID", fun_SetNull(clsPharmacyClass.ReportPharmacist))
Dim int_InterventionComplete As Object
Dim sys_NullValue As System.DBNull
Select Case cbo_Filter.SelectedIndex
Case 0
int_InterventionComplete = sys_NullValue
Case 1
int_InterventionComplete = 0
Case 2
int_InterventionComplete = 1
End Select
..SetParameterValue("@InterventionComplete", int_InterventionComplete)
..SetParameterValue("@int_Mode", 1)
Case ReportName.Report_MonthlyActivity
..SetParameterValue("@PharmacistID", fun_SetNull(clsPharmacyClass.ReportPharmacist))
End Select
..SetDatabaseLogon(g_str_Username, g_str_Password, g_str_Server, g_str_Database)
End With
If ysd_Destination.StringValue = "Screen" Then
frm_SuccessMessage.fun_OpenForm _
("Printing to screen - Please wait....")
frm_Viewer.crv_ReportViewer.ReportSource = obj_Report
frm_Viewer.ShowDialog()
Else
frm_SuccessMessage.fun_OpenForm _
("Printing - Please wait....")
obj_Report.PrintToPrinter(1, True, 0, 0)
End If
Return True
Catch ex As Exception
ErrorMessage("Unable to show report " & _
ControlChars.CrLf & "Error Message: " & ex.Message.ToString)
Return False
Finally
obj_Report = Nothing
frm_Viewer = Nothing
End Try
End Function
this is all working fine when it is just one report, but if we have a report which contains a subreport then it fails, i assume you need to logon to the subreports also but im not sure how to.
the subreports also require 4 parameter values to be passed to it
any help would be greatly appreciated
Cheers,
Craig
here is the code we use for calling a single report
************************************************************
Private Function fun_ShowReport() As Boolean
Dim obj_Report As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim frm_Viewer As New frmViewReport
Dim crTableLogonInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
Try
crTableLogonInfo = New TableLogOnInfo
crConnectionInfo = New ConnectionInfo
crConnectionInfo.DatabaseName = g_str_Database
crConnectionInfo.ServerName = g_str_Server
crConnectionInfo.UserID = g_str_Username
crConnectionInfo.Password = g_str_Password
crTableLogonInfo.ConnectionInfo = crConnectionInfo
With obj_Report
..Load(m_str_ReportFilename)
For Each crTable In .Database.Tables
crTable.ApplyLogOnInfo(crTableLogonInfo)
Next
..SetParameterValue("@FromDate", txt_StartDate.SetDBValue)
..SetParameterValue("@ToDate", txt_EndDate.SetDBValue)
If m_int_ReportName <> ReportName.Report_UserFeedback Then
..SetParameterValue("@HospitalID", fun_SetNull(clsPharmacyClass.ReportHospital))
..SetParameterValue("@WardID", fun_SetNull(clsPharmacyClass.ReportWard))
End If
Select Case m_int_ReportName
Case ReportName.Report_Intervention
..SetParameterValue("@PatientID", 0)
..SetParameterValue("@PharmacistID", fun_SetNull(clsPharmacyClass.ReportPharmacist))
Dim int_InterventionComplete As Object
Dim sys_NullValue As System.DBNull
Select Case cbo_Filter.SelectedIndex
Case 0
int_InterventionComplete = sys_NullValue
Case 1
int_InterventionComplete = 0
Case 2
int_InterventionComplete = 1
End Select
..SetParameterValue("@InterventionComplete", int_InterventionComplete)
..SetParameterValue("@int_Mode", 1)
Case ReportName.Report_MonthlyActivity
..SetParameterValue("@PharmacistID", fun_SetNull(clsPharmacyClass.ReportPharmacist))
End Select
..SetDatabaseLogon(g_str_Username, g_str_Password, g_str_Server, g_str_Database)
End With
If ysd_Destination.StringValue = "Screen" Then
frm_SuccessMessage.fun_OpenForm _
("Printing to screen - Please wait....")
frm_Viewer.crv_ReportViewer.ReportSource = obj_Report
frm_Viewer.ShowDialog()
Else
frm_SuccessMessage.fun_OpenForm _
("Printing - Please wait....")
obj_Report.PrintToPrinter(1, True, 0, 0)
End If
Return True
Catch ex As Exception
ErrorMessage("Unable to show report " & _
ControlChars.CrLf & "Error Message: " & ex.Message.ToString)
Return False
Finally
obj_Report = Nothing
frm_Viewer = Nothing
End Try
End Function