Passing parameters to report

I'm using ASP to call  a report which use a stored procedure with a single parameter.
Here's what i'm doing
dim fileName,ObjectFactory,ReportAppSession,HTMLViewer,ReportClientDocument,OpenReport
   fileName = Server.MapPath(Request.QueryString("ReportName"))
     response.Write fileName
   Set ObjectFactory = Server.CreateObject("CrystalReports.ObjectFactory.2")
    Set ReportAppSession = ObjectFactory.CreateObject("CrystalReports.ReportAppSession")
   Set HTMLViewer = ObjectFactory.CreateObject("CrystalReports.CrystalReportViewer")
   Set ReportClientDocument = ReportAppSession.CreateService("CrystalReports.ReportClientDocument")

   HTMLViewer.EnableParameterPrompt = false
   HTMLViewer.EnableLogonPrompt = false
   HTMLViewer.IsOwnPage = true
   HTMLViewer.URI = "pageviewer-new.asp?ReportName=" + Server.URLEncode(fileName)

   ReportClientDocument.Open fileName
   Set OpenReport = ReportClientDocument

   For Each Field in OpenReport.DataDefinition.ParameterFields
       
        Set paramToChange = Field
         
       Set parameterFieldDiscreteValue = ObjectFactory.CreateObject("CrystalReports.ParameterFieldDiscreteValue")
       parameterFieldDiscreteValue.Value = CStr(Request.QueryString(paramToChange.Name))
         
       Set parameterField = ObjectFactory.CreateObject("CrystalReports.ParameterField")
       paramToChange.CopyTo parameterField
       parameterField.CurrentValues.Add(parameterFieldDiscreteValue)
       Set parameterFieldController = OpenReport.DataDefController.ParameterFieldController
       parameterFieldController.Modify paramToChange, parameterField

   Next
   OpenReport.DatabaseController.Logon "UID","PWD"

   HTMLViewer.ReportSource = OpenReport

   HTMLViewer.ProcessHttpRequest Request, Response

 
it gives me an error "The parameter is incorrect
webReporting.dll error '80070057'  
" at line 38 which is the last statement " HTMLViewer.ProcessHttpRequest Request, Response"

Any ideas?
primo007Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
All Courses

From novice to tech pro — start learning today.