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.Enabl eParameter Prompt = 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.ParameterFieldN ame = "ProductID"
' Set the first discrete value and pass it to the parameter
discreteVal.Value = ProductID
paramField.CurrentValues.A dd(discret eVal)
paramFields.Add(paramField )
' Set the parameter fields collection into the viewer control.
CrystalReportViewer1.Param eterFieldI nfo = paramFields
CrystalReportViewer1.Repor tSource = 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
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.Enabl
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.ParameterFieldN
' Set the first discrete value and pass it to the parameter
discreteVal.Value = ProductID
paramField.CurrentValues.A
paramFields.Add(paramField
' Set the parameter fields collection into the viewer control.
CrystalReportViewer1.Param
CrystalReportViewer1.Repor
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
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.
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ahaa, sneaky line of code in the page init section CrystalReportViewer1.Repor tSource = New Report1()
Forgot this was there when I was messing about.
Forgot this was there when I was messing about.
Thanks. Glad i could help
mlmcc
mlmcc
whenver i design a crystal report from within dot net environment, it gives me this error
CrystalDecisions.CrystalRe ports.Engi ne.LogOnEx ception: Logon failed.
the code i have used is as follows:
Dim rpt As ReportDocument
rpt = New ReportDocument
CrystalReportViewer1.DataB ind()
rpt.Load("c:\inetpub\wwwro ot\west\re ports\rep1 .rpt", OpenReportMethod.OpenRepor tByDefault )
rpt.SetDatabaseLogon("sa", "123", "server1", "eastdb")
CrystalReportViewer1.Repor tSource = rpt
CrystalReportViewer1.ShowF irstPage()
somebody please tell me, where i m wrong!!!
CrystalDecisions.CrystalRe
the code i have used is as follows:
Dim rpt As ReportDocument
rpt = New ReportDocument
CrystalReportViewer1.DataB
rpt.Load("c:\inetpub\wwwro
rpt.SetDatabaseLogon("sa",
CrystalReportViewer1.Repor
CrystalReportViewer1.ShowF
somebody please tell me, where i m wrong!!!
Heritagecomputer - Please ask you rown question
mlmcc
mlmcc
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