I'm a bit at wits end here. I have a asp.net application, and I'm trying to view a Crystal Report. I've done this with another application just fine. The only difference with my current app is that I pass a starting and ending date parameter. I can call up the Report fine. But as soon as I hit the next page button, I have issues. I found the KB example 1985571 about using sessions. I was mostly able to convert that to vb.net, except for the me.init sub. Updated to the last service pack as well. What I do get is this message when clicking Next Page in the Report Viewer:
Error The types of the parameter field and parameter field current values are not compatible.
I was getting the pop-up to enter in the start and end dates parametes and to login, but those are gone now that I have the session. What about in the .aspx? These settings? I've tried them both ways to no avail. ReuseParameterValuesOnRefresh="True" EnableParameterPrompt="False"
Here is my code - any ideas?
Public Class Test
Inherits System.Web.UI.Page
Private designerPlaceholderDeclaration As System.Object
Dim myReport As New ReportDocument()
Private Sub cmdView_Click(sender As Object, e As EventArgs) Handles cmdView.Click
If ((Session("Report") Is Nothing)) Then
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
myReport.Load(Server.MapPath("Reports/CTEmpAttendance.rpt"))
'Pass parameters to the report
Dim startdate, enddate As Date
startdate = FormatDateTime(txtStartDate.Text, DateFormat.ShortDate)
enddate = FormatDateTime(txtEndDate.Text, DateFormat.ShortDate)
txtStartDate.Text = startdate.ToString("yyyy-MM-dd")
txtEndDate.Text = enddate.ToString("yyyy-MM-dd")
myReport.SetParameterValue(0, txtStartDate.Text)
myReport.SetParameterValue(1, txtEndDate.Text)
Dim myTables As Tables = myReport.Database.Tables
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
'login stuff here....left out of code for demo
myTableLogonInfo.ConnectionInfo = myConnectionInfo
myTable.ApplyLogOnInfo(myTableLogonInfo)
Next
CrystalReportViewer1.ReportSource = myReport
CrystalReportViewer1.DataBind()
Else
myReport = CType(Session("Report"), ReportDocument)
' Now send the report to the viewer
CrystalReportViewer1.ReportSource = myReport
End If
End Sub
Private Sub Test_Init(sender As Object, e As EventArgs) Handles Me.Init
If Not IsPostBack Then
Dim start As Integer
Dim endday As Integer
Dim dt As DateTime = DateTime.Now
Dim startdate, enddate As Date
start = -7
endday = -1
startdate = FormatDateTime(Date.Now().AddDays(start), DateFormat.ShortDate)
enddate = FormatDateTime(Date.Now().AddDays(endday), DateFormat.ShortDate)
txtStartDate.Text = startdate.ToString("yyyy-MM-dd")
txtEndDate.Text = enddate.ToString("yyyy-MM-dd")
Else
If Not IsNothing(CType(Session("Report"), ReportDocument)) Then
myReport = CType(Session("Report"), ReportDocument)
'hard coded the dates in the correct format to be sure
myReport.SetParameterValue(0, "2020-05-20")
myReport.SetParameterValue(1, "2020-05-20")
CrystalReportViewer1.ReportSource = myReport
End If
End If
End Sub