Solved

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

Posted on 2008-10-07
4
770 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
4 Comments
 
LVL 100

Accepted Solution

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

Assisted Solution

by:UnifiedIS
UnifiedIS earned 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Class object 2 26
Cyrstal Reports formula to check IsNull 8 22
What .NET URL re-routing tool did I use? 2 36
Visual Studio 2015 Source Code Control 10 29
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
A short film showing how OnPage and Connectwise integration works.

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now