Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using Stored Procedure, How do I set parameter in Crystal Reports .NET "Missing Parameter Values"

Posted on 2008-10-07
4
Medium Priority
?
782 Views
Last Modified: 2013-12-17
Hello all,

I've spent at least a day pulling my hair out on this one.  I've searched many a forum for a solution.  This issue seems fairly straight forward but I it seems that I'm missing something.  I created a SPROC in SQL Server 2005 that expects a param of type string.  I created a simple crystal report in VS 2008 (I tried using both a DataSet and OLE DB connection to the SPROC) and used the following code to set the param.  I've tried various ways to implement this to no avail.  By setting the 'EnablePrompt' property on the report viewer, I can type in a value and data is returned.  Please provide some insight!  

ReportDocument rd = new ReportDocument();
rd.load(Server.MapPath("some path");
CrystalReportViewer1.ReportSource = rd;
ParameterFields pFS = CrystalReportViewer1.ParameterFieldInfo;
ParameterValues pVs = new ParameterValues();
ParameterDiscreateValue = pDV = new ParameterDiscreateValue();
pDV.Value = "someStringValue";
pVs.Add(pDV);
ParameterField pF = pFS["@someParam"];
pF.CurrentValues = pVs;
CrystalReportViewer1.DataBind();



0
Comment
Question by:cUnSharp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 1000 total points
ID: 22660482
0
 
LVL 18

Assisted Solution

by:UnifiedIS
UnifiedIS earned 1000 total points
ID: 22660629
I run my reports with a loop that compares the parameter name with stored values in a database.  You should be able to tweak to fit.

ReportDocument rd = new ReportDocument();
rd.load(Server.MapPath("some path");
 
ParameterFields pFS = rd.ParameterFields
ParameterValues pVs = ParameterValues();
ParameterField pF
for each pF in pFS
          if pF.Name = "SomeParameterName" Then
                   pVS = pFS.CurrentValues
                   ParameterDiscreateValue pDV = new ParameterDiscreteValue();
                   pDV.Value = "SomeValue"
                   pVS.Add(pDV)
           endif
next
CrystalReportViewer1.ReportSource = rd;
'Not sure if you need the bind, I only set the report source
'CrystalReportViewer1.DataBind();

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question