Showing results for 
Search instead for 
Did you mean: 

Parameter is Incorrect Error on ASP page

Former Member
0 Kudos

When running reports form my ASP page the reports will run fine and display. However if I leave the first report open and run another report and then go back and click on the first report I get an error. The error is "The parameter is incorrect". I know what is happening but don't know how to keep if from occuring.

The problem is that both reports on the client are pointing to the same report in memory on the server.

My Page_load code is as follows

If Not Page.IsPostBack or Session("rptDoc") is nothing Then
      Dim sReport As String = Server.UrlDecode(Request.QueryString("Report"))
      Dim sGroup As String = Server.UrlDecode(Request.QueryString("Group"))

      'Create the Report object and create a session variable.  Used on postback
      myReportDocument = New ReportDocument
      Session("rptDoc") = myReportDocument
      CrystalReportViewer1.ReportSource = myReportDocument

      Dim myconn As New ConnectionInfo
      Dim myTables As New TableLogOnInfos

      myTables = Me.CrystalReportViewer1.LogOnInfo

      Dim sConStr As String = ConfigurationManager.ConnectionStrings(sGroup).ConnectionString.ToString
      Dim sArr As String() = sConStr.Split(";")
      With myconn
        For i As Integer = 0 To sArr.Length - 1
          If sArr(i).Contains("Data Source") Then
            .DatabaseName = sArr(i).Substring(InStr(sArr(i), "="))
          End If
          If sArr(i).Contains("User") Then
            .UserID = sArr(i).Substring(InStr(sArr(i), "="))
          End If
          If sArr(i).Contains("Password") Then
            .Password = sArr(i).Substring(InStr(sArr(i), "="))
          End If
        Next i
      End With

      For Each tbl As TableLogOnInfo In myTables
        tbl.ConnectionInfo = myconn

      Me.CrystalReportViewer1.EnableDatabaseLogonPrompt = False
      If myReportDocument.ParameterFields.Count > 0 Then
        Me.CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.ParameterPanel
        Me.CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None
      End If
      myReportDocument = CType(Session("rptDoc"), ReportDocument)
      CrystalReportViewer1.ReportSource = myReportDocument
      'crReportDocument.ExportToDisk(ExportFormatType.CrystalReport, "C:\\Windows\\temp\\SampleReport.rpt");

    End If

I am certain it has to do with the session information. Any help would be greatly appreciated. We are trying to deploy to production this weekend!

Thanks, Bob

Accepted Solutions (1)

Accepted Solutions (1)

Active Contributor
0 Kudos

Hey Bobby,

You are storing the report in session, and opening more than one window. This is probably causing the second report open to overwrite the first. The parameter information is stored in viewstate. So it is applying the wrong parameter information to the wrong report.

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks for your response. Based on the information in my original post, I recognize what is happening. I was looking for an example of how to fix the issue. I was hoping someone would have a good example of how they run multiple reports from an ASP application. Specifically the code used to create the session information.