Share via


Error :"Missing parameter values" while exporting a crystal report to PDF in VS2005

Question

Friday, June 15, 2007 7:54 AM

Hi,

I have a project which is converted from VS2003 to VS2005 .I got the code to export the crystal report to pdf and is working in VS2003,but in VS2005 it showing an Error :"Missing Parameter Values" and it is runtime.The code is as shown below.

Namespaces used:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared 

 

        Dim MyReport As New ReportDocument
        Dim strExportFile As String
        Dim objExOpt As New ExportOptions
        Dim objDiskOpt As New DiskFileDestinationOptions
        strExportFile = ReportName & ".pdf"
        MyReport.Load(Server.MapPath("." & "/Reports/" & ReportName & ".rpt"))
        MyReport.SetParameterValue("compname", objRptInfo.rptCompName)
        MyReport.SetParameterValue("compaddress", objRptInfo.rptCompAddress)
        MyReport.SetParameterValue("compshname", objRptInfo.rptCompSName)
        MyReport.SetParameterValue("mainhead", RptHead)
        MyReport.SetParameterValue("categoryhead", cathead)
        MyReport.SetParameterValue("category", stype)
        MyReport.SetParameterValue("itemhead", FormSubItem)
        MyReport.SetParameterValue("itemtype", sitem)
        MyReport.SetParameterValue("rpttype", rptstyle)
        MyReport.SetDatabaseLogon(objRptInfo.CrysRptUser, objRptInfo.CrysRptPwd)
        MyReport.SetDataSource(ds.Tables(0))
        Dim RowCount As String
        RowCount = ds.Tables(0).Rows.Count().ToString()
        objDiskOpt.DiskFileName = Server.MapPath(".") & "/Reports/" & strExportFile
        objExOpt = MyReport.ExportOptions
        objExOpt.ExportDestinationType = ExportDestinationType.DiskFile
        objExOpt.ExportFormatType = ExportFormatType.PortableDocFormat
        **MyReport.Export()**Error is here
        MyReport.Close()
        Return strExportFile

 

Please do necessary help................................

Manu G 

All replies (5)

Thursday, June 21, 2007 1:36 AM

Manu,

 

I had the same problem. It turns out that in the new version (2005), when you set the datasource it clears all of the current parameters, so you have to set the datasource and logon info before you set the parameter values.

 


Wednesday, June 27, 2007 12:58 PM

I had the same issue too. Many thanks johnnesbitt. I was binding the reportsource after all of the parameter definitions. I simply moved it before them and everything was fine.


Saturday, August 18, 2007 5:24 AM

Set Parameter Current Value in Export Method

For Discrete Parameters   -   

ReportDocument.SetParameterValue("Parameter_Name", Value) 

For Range Parameters -

Dim RangePram1 As New ParameterRangeValue
RangeParam1.StartValue = Application("FromDate").ToString
RangeParam1.EndValue = Application("Todate").ToString
ReportDocument1.SetParameterValue("P_dateRange", Todate_Value)

 

Regards 

 


Wednesday, June 11, 2008 12:59 AM

 Dim MyReport As New ReportDocument
        Dim strExportFile As String
        Dim objExOpt As New ExportOptions
        Dim objDiskOpt As New DiskFileDestinationOptions
        strExportFile = ReportName & ".pdf"
        MyReport.Load(Server.MapPath("." & "/Reports/" & ReportName & ".rpt"))
        MyReport.SetParameterValue("compname", objRptInfo.rptCompName)
        MyReport.SetParameterValue("compaddress", objRptInfo.rptCompAddress)
        MyReport.SetParameterValue("compshname", objRptInfo.rptCompSName)
        MyReport.SetParameterValue("mainhead", RptHead)
        MyReport.SetParameterValue("categoryhead", cathead)
        MyReport.SetParameterValue("category", stype)
        MyReport.SetParameterValue("itemhead", FormSubItem)
        MyReport.SetParameterValue("itemtype", sitem)
        MyReport.SetParameterValue("rpttype", rptstyle)
        MyReport.SetDatabaseLogon(objRptInfo.CrysRptUser, objRptInfo.CrysRptPwd)
        MyReport.SetDataSource(ds.Tables(0))
        Dim RowCount As String
        RowCount = ds.Tables(0).Rows.Count().ToString()
        objDiskOpt.DiskFileName = Server.MapPath(".") & "/Reports/" & strExportFile
        objExOpt = MyReport.ExportOptions
        objExOpt.ExportDestinationType = ExportDestinationType.DiskFile
        objExOpt.ExportFormatType = ExportFormatType.PortableDocFormat
        **MyReport.Export()**Error is here
        MyReport.Close()
        Return strExportFile


Wednesday, June 11, 2008 5:57 AM

guys please check outh the following

http://forums.asp.net/t/1272667.aspx