Link to home
Start Free TrialLog in
Avatar of lawrmc
lawrmc

asked on

Asp.net Crystal 10 passing parameters

Hi,
I am using a webform with one text box to pass a string parameter to a CR. The code is below.
When the page loads it asks..
The report you requested requires further information.

--------------------------------------------------------------------------------
and has a textbox for the param. If I ignore this and enter my param the CR opens and displays correctly. I thought setting
CrystalReportViewer1.EnableParameterPrompt = False  in   the page load would stop this, but I get an error
Missing parameter values.

Anyone have any suggestions?

 Private Sub GenerateRPT(ByVal ProductID As String)
        ' Declare variables needed to pass the parameters
        ' to the viewer control.
        Dim paramFields As New ParameterFields()
        Dim paramField As New ParameterField()
        Dim discreteVal As New ParameterDiscreteValue()
        'Dim rangeVal As New ParameterRangeValue()

        ' The first parameter is a discrete parameter with multiple values.

        ' Set the name of the parameter field, this must match a
        ' parameter in the report.
        paramField.ParameterFieldName = "ProductID"

        ' Set the first discrete value and pass it to the parameter
        discreteVal.Value = ProductID
        paramField.CurrentValues.Add(discreteVal)

 
        paramFields.Add(paramField)

        ' Set the parameter fields collection into the viewer control.
        CrystalReportViewer1.ParameterFieldInfo = paramFields
        CrystalReportViewer1.ReportSource = New Report1()


    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ProdId As String
        ProdId = txtProductID.Text
        GenerateRPT(ProdId)
    End Sub
Avatar of Mike McCracken
Mike McCracken

I suspect the name is incorrect or the value is the wrong type.

From VB the names are of the form {?ParamName}.  I don't know if the ASP interface requires you to use the { } or the ?.  you might try that.

Here are some CR9 ASP examples.  I don't think much changed.
http://support.businessobjects.com/communityCS/FilesAndUpdates/aspxmps9.exe.asp

mlmcc
Avatar of lawrmc

ASKER

Hi,
the parameter name is OK and all the functionality works when I enter a param in my textbox. I just get hit with my textbox for the parameter and an auto generated textbox asking for a parameter. I want to disable parameter prompting without getting the errors on load.
Avatar of lawrmc

ASKER

mmm Tried the same code on my laptop and it works!! Tried it with both access and SQL Server dbs and reports..
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lawrmc

ASKER

Ahaa, sneaky line of code in the page init section   CrystalReportViewer1.ReportSource = New Report1()
Forgot this was there when I was messing about.
Thanks.  Glad i could help

mlmcc
whenver i design a crystal report from within dot net environment, it gives me this error
CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.
the code i have used is as follows:

Dim rpt As ReportDocument
        rpt = New ReportDocument
        CrystalReportViewer1.DataBind()
        rpt.Load("c:\inetpub\wwwroot\west\reports\rep1.rpt", OpenReportMethod.OpenReportByDefault)
        rpt.SetDatabaseLogon("sa", "123", "server1", "eastdb")
        CrystalReportViewer1.ReportSource = rpt
        CrystalReportViewer1.ShowFirstPage()
somebody please tell me, where i m wrong!!!
Heritagecomputer - Please ask you rown question

mlmcc