Export Multiple Crystal Reports ASP.NET
Posted
by AProgrammer
on Stack Overflow
See other posts from Stack Overflow
or by AProgrammer
Published on 2009-08-31T16:38:08Z
Indexed on
2010/04/02
15:03 UTC
Read the original article
Hit count: 413
Hey all,
I want to export 2 different reports when I click an Export button. The problem is the routine only fires once and I only get one report to print out. Am I doing something wrong? I think it has something to do with the HTTPResponse, but I'm not sure.
Here's my code:
Dim badgeSize As Integer = 0 'Drop Down selection
Dim badgeData As New DataSet 'Visitor Badge Data
Dim badgeEmployeeData As New DataSet 'Employee Badge Data
Dim badgeTotals As Integer = 0 'Totals for both
badgeSize = ddlBadgeSize.SelectedValue
' Get Visitor Data
badgeData = _DatabaseAccess.GetProjectReportData(sessionInfo.myEventID, sessionInfo.EventCreator)
' Get Employee Data
badgeEmployeeData = _DatabaseAccess.GetProjectReportEmployeeData(sessionInfo.myEventID, sessionInfo.EventCreator)
'Obtain Totals
badgeTotals = badgeData.Tables(0).Rows.Count + badgeEmployeeData.Tables(0).Rows.Count
If badgeTotals = 0 Then
ShowMessage("There are no badges to print.")
Exit Sub
End If
If badgeSize.Equals(0) Then 'Small
If badgeEmployeeData.Tables(0).Rows.Count > 0 Then
If badgeEmployeeData.Tables(0).Rows.Count >= 6 Then
PrintProjectBadges(badgeEmployeeData, "Employee", badgeSize)
Else
PrintStandardDymo(badgeEmployeeData, "Employee", 1)
End If
End If
If badgeData.Tables(0).Rows.Count > 0 Then
If badgeData.Tables(0).Rows.Count >= 6 Then
PrintProjectBadges(badgeData, "Visitor", badgeSize)
Else
PrintStandardDymo(badgeData, "Visitor", 1)
End If
End If
else
'do somethign else
endif
And the Report Code:
Private Sub PrintProjectBadges(ByVal theData As DataSet, ByVal badgeType As String, ByVal badgeSize As Integer)
Dim ourReport As New ReportDocument
Dim crConnectionInfo As New ConnectionInfo(SetCrystalConnection)
If badgeSize = 0 Then
Try
If badgeType = "Visitor" Then
ourReport.Load(Server.MapPath("SmallProjectBadge.rpt"), OpenReportMethod.OpenReportByDefault) 'LIVE SERVER USE
Else
ourReport.Load(Server.MapPath("SmallProjectEmployeeBadge.rpt"), OpenReportMethod.OpenReportByDefault) 'LIVE SERVER USE
End If
Catch ex As Exception
Dim TraceList As New ArrayList
TraceList.Add("DBLog")
DatabaseAccess.WriteToErrorLog("Visitor Registration", "Printing Project Badges", ex.Message, TraceEventType.Information, 1, TraceList)
Exit Sub
End Try
ourReport.SetDataSource(theData.Tables("Project"))
Else
'Do somethign else...
End If
Response.Buffer = True
'Clear the response content and headers
Response.ClearContent()
Response.ClearHeaders()
SetLogon(ourReport, crConnectionInfo)
'Export the Report to Response stream in PDF format and file name Customers
ourReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, True, "Visitor_Badges")
Response.End()
'Response.Close()
End Sub
Any Help would be much appreciated.
© Stack Overflow or respective owner