Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: Missing Parameter Values Post Reply Post New Topic
Author Message
googly69
Newbie
Newbie


Joined: 18 Jun 2007
Online Status: Offline
Posts: 2
Quote googly69 Replybullet Topic: Missing Parameter Values
    Posted: 18 Jun 2007 at 9:12am
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;

   
 //.ApplyCurrentValues(curValues);
      
    }
    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)
    {

    }
}
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 21 Jun 2007 at 4:44pm

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)
{
  if (parafld.DiscreteOrRangeKind.ToString() == "DiscreteValue")
  {
    discreteVal.Value =
           Request.QueryString[parafld.ParameterFieldName];
    if (discreteVal.Value != null)
    {
      curvalues.Add(discreteVal);
      parafld.ApplyCurrentValues(curvalues);
    }
  }
}
 
-Dell


Edited by hilfy - 21 Jun 2007 at 4:46pm
IP IP Logged
googly69
Newbie
Newbie


Joined: 18 Jun 2007
Online Status: Offline
Posts: 2
Quote googly69 Replybullet Posted: 22 Jun 2007 at 5:23am
Thank you.  I'll work this in.
IP IP Logged
JeremyDP
Newbie
Newbie
Avatar

Joined: 25 Jul 2007
Location: United States
Online Status: Offline
Posts: 2
Quote JeremyDP Replybullet Posted: 25 Jul 2007 at 10:10am
I have used the code (converted to VB) posted by hilfy and get the following error:
 
Failed to open a rowset. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for SQL Server Description: Procedure or Function 'sp_xxxx' expects parameter '@ppppp', which was not supplied. SQL State: 42000 Native Error: Failed to open a rowset. Error in File
 
I am getting this same error, however it is not a result of moving from DEV to PROD.
 
I have also tried the following code:
 
Dim objReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
Dim paraValue As New CrystalDecisions.Shared.ParameterDiscreteValue
Dim currValue As CrystalDecisions.Shared.ParameterValues
Dim sParValPair() As String
Dim sValue() As String
Dim iIndex As Integer
Dim crFieldDef As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions
Dim crFieldLoc As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition
ConInfo.ConnectionInfo.ServerName = modLibrary.m_sDATASOURCE
ConInfo.ConnectionInfo.DatabaseName = modLibrary.m_sDATABASE
ConInfo.ConnectionInfo.IntegratedSecurity = True
objReport.Database.Tables(intCounter).ApplyLogOnInfo(ConInfo)
crFieldDef = objReport.DataDefinition.ParameterFields
sParValPair = sParam.Split(";")
For iIndex = 0 To UBound(sParValPair)
   If InStr(sParValPair(iIndex), "=") > 0 Then
      sValue = sParValPair(iIndex).Split("=")
      crFieldLoc = crFieldDef.Item(sValue(0))
      currValue = crFieldLoc.CurrentValues
      paraValue.Value = sValue(1)
      currValue.Add(paraValue)
      crFieldLoc.ApplyCurrentValues(currValue)
   End If
Next iIndex
 
Any ideas?
 
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 25 Jul 2007 at 6:16pm
The error is not a CR error but an ADO.net error. To troubleshoot this and these are things you may have done....
 
If these works in test but not production, make sure the execute permissions for the user have been granted.  I have failed to GRANT permissons more times than I care to admit.
 
A second thing to look at is if you are using a .Net dataobject.  Search your project code for the name of the test server. I had a similar problem and found that while I was changing the connection string in one location there were other locations that held test server connections and not production.
 
 
I would test the stored procedure by trying the value from drop down box that is raising the error. You do this by executing the stored proc and then passing the parameters, depending of database. You may be require to hand code the values and then execute the sp.
 
 
I would hard code the parameter values in the report selection formula to make certain they work there.
 
If it checks out I make certain that the data typing is correct. I have never written a CR parameter to pass through to a database parameter, but I suspect that CR having fewer datatypes creates room for errors.
 
Finally, I would step through the code to make certain everything passed is as expected. You may want to create a few objects to read the values as they being passed to be sure they are what you want.
 
Maybe there is something here that will help isolate the problem.
 
Regards
 
John W.
 
 
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 25 Jul 2007 at 6:29pm
Here is a link that may help. Only you will know. While it does not mention the Failed to Open A Rowset Error... I read elsewhere that it does in fact have to do with that kind of error.
 
 
John W.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.029 seconds.