Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: Report printing error Post Reply Post New Topic
Author Message
momer79
Newbie
Newbie


Joined: 23 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 12
Quote momer79 Replybullet Topic: Report printing error
    Posted: 22 May 2009 at 3:21pm
Hi,

I am wondering if someone can help me with this problem in crystal report.

I am having problem in printing crystal report in my asp.net project. I am using crystal report XI with asp.net.

Report can be printed if its one main report but doesn't work if i add subreport in Main-Report.

I am using one dataset for both main and subreport. If report contains one page then it works fine and i can print report without any error message but
it doesn't work if report has more than one page and  i get following error message when i click on print button of crystal report viewer.

-----------------------------------------

Failed to export using the options you specified. Please check your options and try again.

-----------------------------------------


There are few drop down controls on the page which are filled on page load event and once user select the items from drop down control and click
filter button then i am filtering dataset and setting datasource to report.

Here is the code:

---------------------------------------------------------------------------

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            InitialiseData()  ' Here i am filling drop down list controls
        Else
            BindReport()
        End If
End Sub


Private Sub InitialiseData() 
        GetEmployeeID()
        GetDepartments()
        GetManagers()
        GetCostCentres()
        GetContractType()
        GetDivisions()

        Get_Cut_Off_Dates()
        Set_CutOff_Dates()
End Sub



Private Sub BindReport()

        Try
           

            Dim myRpt As New ReportDocument


            CrystalReportViewer1.Visible = True
            m_Reply = m_Lots.BFD_GetBFF(ddltxtStartdate.SelectedItem.Text, ddltxtEnddate.SelectedItem.Text)

            If m_Reply.ReplyStatus.ErrorCode = 0 Then
                myRpt.Load(Server.MapPath("../Reports/BF_Summary.rpt"))

                myRpt.SetDataSource(SetDatatable(m_Reply.Data.Tables(0).Select(SetFilter))) '(m_Reply.Data.Tables(0).Select(SetFilter))

                CrystalReportViewer1.ReportSource = myRpt
                CrystalReportViewer1.DataBind()

                CrystalReportViewer1.ToolbarStyle.Width = New Unit("756px")

            Else
                m_UIHelp.RedirectToErrorPage(Response, THIS_PAGE, , m_Reply.ReplyStatus.ErrorMessage & " - " & "Bind Report")
            End If

        Catch ex As Exception
            m_UIHelp.RedirectToErrorPage(Response, THIS_PAGE, , "Bind Report", ex)
        Finally
            m_Reply = Nothing
        End Try

End Sub





Function SetDatatable(ByRef dataRows() As DataRow) As DataTable
        Dim dt As New DataTable
        Dim r As DataRow

        dt.Columns.Add(New DataColumn("FIRST_NAME", System.Type.GetType("System.String")))
        dt.Columns.Add(New DataColumn("LAST_NAME", System.Type.GetType("System.String")))
        dt.Columns.Add(New DataColumn("CONTRACT_TYPE_", System.Type.GetType("System.String")))
        dt.Columns.Add(New DataColumn("MANAGER_NAME", System.Type.GetType("System.String")))
        dt.Columns.Add(New DataColumn("DAYS", System.Type.GetType("System.Decimal")))
        dt.Columns.Add(New DataColumn("OCCASIONS", System.Type.GetType("System.Decimal")))
        dt.Columns.Add(New DataColumn("BF", System.Type.GetType("System.Decimal")))
        dt.Columns.Add(New DataColumn("COMMENTS", System.Type.GetType("System.String")))


        Try
            For Each r In dataRows
                dt.ImportRow(r)
            Next

        Catch ex As Exception
            m_UIHelp.RedirectToErrorPage(Response, THIS_PAGE, , "SetDatatable", ex)
        End Try

        SetDatatable = dt

End Function



---------------------------------------------------------------------------


I have tried to bind the report on page_Init event but i am still not able to print the report which contains subreport.

Anyone know what i am doing wrong?

Thanks
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.000 seconds.