Skip to Content
0
Former Member
Jan 07, 2011 at 10:43 PM

VS2008 CR basic Data not saving with report

25 Views

I have a Windows forms app with a CR developed in VS2008. The report displays correctily in the report viewer control and I also save it as a .rpt file. When I open this file in Crystal Reports Viewer 2008 I get the error that there is no saved data. The data source for the report is a DataView. Here is my code:

' set sort key of Rpt1Ds view

If Me.radRptSeqn.Value = "A" Then

sortKey = "Account ASC, Contract ASC"

ElseIf Me.radRptSeqn.Value = "C" Then

sortKey = "Contract ASC"

ElseIf Me.radRptSeqn.Value = "N" Then

sortKey = "Surname ASC, Contract ASC"

End If

AddRpt1Summary()

Dim dv1 As DataView = New DataView(Me.Rpt1Ds.Tables(0), "", sortKey, DataViewRowState.CurrentRows)

dv1.Table.TableName = "RRIFYePaymentsTable"

CRpt1.SetDataSource(dv1)

Dim dv2 As DataView = New DataView(Me.Rpt1Ds.Tables(1), "", "TotPymtFreq ASC", DataViewRowState.CurrentRows)

dv2.Table.TableName = "RRIFYePaymentsSummaryTable"

CRpt1.Subreports.Item(0).SetDataSource(dv2)

CRpt1.SetParameterValue("CUName", cuname)

CRpt1.SetParameterValue("SystemDateOR", MainForm.MySystemDate)

CRpt1.SetParameterValue("AccrualDate", Me.dtpIntAcrlDate.Value)

CRpt1.SetParameterValue("RptTitle", "RRIF ANNUAL PAYMENTS")

CRpt1.SetParameterValue("IsDetailed", Me.chkRptDetail.CheckedValue)

If Me.radRptDest.Value <> "F" Then

CRpt1.PrintOptions.PrinterName = Me.cmbPrinter.Text

End If

CRpt1.ReportOptions.EnableSaveDataWithReport = True

CRpt1.ReportOptions.EnableSaveSummariesWithReport = True

rptViewer.CrystalReportViewer1.ReportSource = CRpt1

rptViewer.CrystalReportViewer1.Zoom(1) ' set to page width

rptViewer.Show()

If Me.radRptDest.Value = "F" OrElse Me.radRptDest.Value = "B" Then

fileName = "RrifYePymts" & dateText & ".rpt"

Me.RptFullPath = SaveRSPReportFile(fileName, CRpt1)

End If