Crystal report parameter has no value

I'm getting the "Missing Parameter Values." error when I try to pass a value from a drop down list into the report. The report itself is based on a stored proc. I'm a newbie to .Net and I've been stumbling along trying to piece together this stuff. I can view the value of the parameter until it's passed into the report (which is viewed in a crystal report viewer control on another page) Any help in this matter is greatly appreciated. My code is as follows:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

public partial class utilrptview : System.Web.UI.Page
protected void SetParameterFields()
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("Reports\\util2.rpt"));
ParameterFields paramFields = CrystalReportViewer1.ParameterFieldInfo;
ParameterField paramField = paramFields["@machineid"];
ParameterValues curValues = paramField.CurrentValues;
ParameterDiscreteValue discreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue();

discreteValue.Value = Request.QueryString["machineid"];
curValues.Add(discreteValue);
CrystalReportViewer1.ParameterFieldInfo = paramFields;

>
protected void Page_Load(object sender, EventArgs e)
ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("Reports\\util2.rpt"));

// Get connection settings from AppSettings in Web.Config
string strConnInfo = ConfigurationManager.AppSettings["CrystalReportConnection"].ToString();
string[] connValues = strConnInfo.Split(';');
string serverName = connValues[0];
string dbName = connValues[1];
string userID = connValues[2];
string password = connValues[3];

rpt.SetDatabaseLogon(userID, password);
ReportLogOn();
//rpt.Refresh();
SetParameterFields();
CrystalReportViewer1.ReportSource = rpt;


>
private void ReportLogOn()

TableLogOnInfos tableLogOnInfos = new TableLogOnInfos();//CrystalReportViewer1.LogOnInfo;
string strConnInfo = ConfigurationManager.AppSettings["CrystalReportConnection"].ToString();
string[] connValues = strConnInfo.Split(';');
string serverName = connValues[0];
string dbName = connValues[1];
string userID = connValues[2];
string password = connValues[3];

ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = serverName;
connectionInfo.DatabaseName = dbName;
connectionInfo.UserID = userID;
connectionInfo.Password = password;
TableLogOnInfo tbl = new TableLogOnInfo();

tbl.ConnectionInfo = connectionInfo;
tableLogOnInfos.Add(tbl);
CrystalReportViewer1.LogOnInfo = tableLogOnInfos;

protected void CrystalReportViewer1_Init(object sender, EventArgs e)

It looks like you're not completely setting the parameter. Here's a code snippet for how we set parameters:

ParameterDiscreteValue discreteVal = new ParameterDiscreteValue();ParameterRangeValue rangeVal = new ParameterRangeValue();ParameterValues curvalues = new ParameterValues();foreach (ParameterFieldDefinition parafld in

crReport.DataDefinition.ParameterFields)
Request.QueryString[parafld.ParameterFieldName]; if (discreteVal.Value != null) >
>

Edited by hilfy - 21 Jun 2007 at 4:46pm