Forum Moderators: open

Message Too Old, No Replies

Parameters in Crystal Reports for Visual Studio.NET

User to enter own parameters on web for crystal reports

         

stevet

11:27 am on Jul 8, 2002 (gmt 0)

10+ Year Member



I would appreciate it if anybody could help me with the following:

I have produced a windows application using VB.NET where users can enter or select their own parameters, i.e they can enter or select a customer number, region, Postcode etc, to view a Crystal Report.

I am now reproducing this application for the web. Using Webforms I can link to a Crystal Report where no parameters are required, with no trouble, also I can link to a Crystal Report that contains Subreports.

My problem is running Crystal Reports over the web that contain parameters, where I would like the user to enter or select their relevant criteria. The parameters are already formulated in Crystal Reports.

However when running a report with parameters, I get the following message:

Server Error in '/GPC Reports' Application.

--------------------------------------------------------------------------------

Missing parameter field current value.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: CrystalDecisions.CrystalReports.Engine.ParameterFieldCurrentValueException: Missing parameter field current value.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[ParameterFieldCurrentValueException: Missing parameter field current value.]
[1].[1]K(String 
, EngineExceptionErrorID 
)
[1].[1]G(String 
--------------------------------------------------------------------------------
, Int32 )
CrystalDecisions.CrystalReports.Engine.FormatEngine.internalSetReportInfo(RequestContext reqContext)
CrystalDecisions.CrystalReports.Engine.FormatEngine.internalGetViewContext(ReportPageRequestContext reqContext, * viewContext)
CrystalDecisions.CrystalReports.Engine.FormatEngine.GetPage(PageRequestContext reqContext)
CrystalDecisions.ReportSource.LocalReportSourceBase.GetPage(PageRequestContext pageReqContext)
CrystalDecisions.Web.ReportAgent.v(Boolean
--------------------------------------------------------------------------------
`)
CrystalDecisions.Web.CrystalReportViewer.OnPreRender(EventArgs e)
System.Web.UI.Control.PreRenderRecursiveInternal() +62
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Page.ProcessRequestMain() +1470

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.0.3705.209; ASP.NET Version:1.0.3705.272

I have tried the online help, but am not sure I understand what to do, that is if it is possible in the first place.

Thanks for any help.

Steve

tomasz

1:33 pm on Jul 8, 2002 (gmt 0)

10+ Year Member



Are you using Report Viewer or Automation Sever?

stevet

3:04 pm on Jul 8, 2002 (gmt 0)

10+ Year Member



I am using CrystalReportViewer on a webform. Server is SQL Server where the database resides. I am a beginner with VB.NET etc but have got by until now.

I think I have to bind the report and add a parameter string on the CrystalReportViewer binding properties, but I am still learning this new software.

Steve

tomasz

6:28 pm on Jul 8, 2002 (gmt 0)

10+ Year Member



Steve,

I prefer to use automation approach due to printing limitations of ReportViewer.

To provide user with true printing options you have to export your report to PDF, Word or excel

I am using formulas instead of parameter fields, they are more flexible to work with, but you should be able to pass parameters as well.

i hope it will help

here is the vb code;

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web.Design

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub CreateReport(ByVal sReport As String, ByVal sReportFormula As String)
' passes report location i.e c:\inetpub\wwwroot\report.rpt
' report custom formula i.e {Table.Field1}>1200
' displays report in browser (temp.pdf)

Dim exportOpts As New ExportOptions()
Dim oRpt As New ReportDocument()

Dim diskOpts As New DiskFileDestinationOptions()
'load report
oRpt.Load(sReport)

'log on to SQL server

Dim crLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
crLogonInfo = oRpt.Database.Tables(0).LogOnInfo
crLogonInfo.ConnectionInfo.ServerName = "ServerName"
crLogonInfo.ConnectionInfo.UserID = "UserName"
crLogonInfo.ConnectionInfo.Password = "Password"
crLogonInfo.ConnectionInfo.DatabaseName = "DatabaseName"
oRpt.Database.Tables(0).ApplyLogOnInfo(crLogonInfo)

'export report to viewer PDF
exportOpts = oRpt.ExportOptions
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat ' ExportFormatType.WordForWindows, ExportFormatType.Excel other formats
'temp file name
diskOpts.DiskFileName = "temp\temp.pdf"
exportOpts.DestinationOptions = diskOpts

Dim ReportFields As FormulaFieldDefinitions = oRpt.DataDefinition.FormulaFields()

oRpt.RecordSelectionFormula = oRpt.RecordSelectionFormula + sReportFormula ' existing formula + custom
' or parameter i.e oRpt.DataDefinition.ParameterFields("Parameter1") = "1"
Try
oRpt.Export()
Response.Redirect("temp.pdf")
Catch
'could not create report
'label1.text="Check your ......."
End Try
End Sub

End Class