Solved

How do I add a dynamic parameter to my crystal report?

Posted on 2013-05-23
10
292 Views
Last Modified: 2013-08-21
I have an ASP .NET 3.5 [C#] application that is using crystal reports. I want to, if possible, design a report (which i've already done), and in the designer add a dynamic parameter field that prompts the user for a value (preferably from a drop down list of valid values) and have it actually work. Currently when I add the parameter field in the designer, save it and then go out to the web page a couple things are happening. 1st, my list (data set) isn't filtered to only the values that meet / match the parameter. 2nd, when i attempt to click into or change the parameter value off to the left upper corner I get an error messag similar to: "Object not set to a value". How do I get this to work as I need it to?
0
Comment
Question by:mikesExpertExchange
  • 6
  • 4
10 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 39191859
How did you create the parameter?

What do you mean it isn't filtered?
It will show all values for the field

mlmcc
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 39191946
parameter creation
param creation
when i say it isn't filtered, i mean that based on the value i pass to the parameter field it appears that i still get all the data and not just the data that matches the parameter. also, when i initially started trying this out today, i would get a: " (?) " symbol in the upper left corner that when i clicked it, it would partially open a drop down that held a list of values for my parameter. it didn't matter though because when i would click in the drop down box to attempt to select a value, I would get the error telling me: "Object not set to an instance" (or some variation of that). but never the less that icon no longer shows up. just some information i thought might be helpful to pass along.
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 39192039
i finally was able to get the parameter icon / symbol to show  up again. in the included picture. if you look just below the printer icon, (upper left corner of the image) you'll see this: (?). when i click on it, to the right of it a box/rectangle appears that is partially cut off near the bottom. within that box/rectangle is a drop down that contains all of the valid possible values for my parameter. how ever, as soon as I try to choose one or edit the value i get the error shown in the image.

parameter error
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 100

Expert Comment

by:mlmcc
ID: 39192077
For filtering, what is your selection formula?

Is the Object not set to an instance from Crystal or the code running the report?

mlmcc
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 39192093
i'm not sure what object the error is referring to. I don't have a formula for the filter. just the parameter that i created. do i need to create a formula, setting a value in the report to the value of the parameter? this is what my Page_Load event looks like, if it helps (see code snippet).

protected void Page_Load(object sender, EventArgs e)
    {
        //SET NO TIME TABLE FOR WEEKLY LOG REPORT
        Utility.PrepNoTimeTable();<wbr ></wbr>

        ReportDocument report;

        if (Session["REP"] == null)
        {

            ReportDocument rpt = new ReportDocument();
            rpt.Load(Server.MapPath("~<wbr ></wbr>/WeeklyLog<wbr ></wbr>RptII.rpt"<wbr ></wbr>).ToString<wbr ></wbr>());

            SqlConnectionStringBuilder<wbr ></wbr> Conn = new SqlConnectionStringBuilder<wbr ></wbr>(Configura<wbr ></wbr>tionManage<wbr ></wbr>r.Connecti<wbr ></wbr>onStrings[<wbr ></wbr>"SQLExpres<wbr ></wbr>s"].Connec<wbr ></wbr>tionString<wbr ></wbr>);
            ConnectionInfo myConnectionInfo = new ConnectionInfo();


            ParameterDiscreteValue discreteVal = new ParameterDiscreteValue();
            ParameterRangeValue rangeVal = new ParameterRangeValue();
            ParameterValues curvalues = new ParameterValues();

            foreach (ParameterFieldDefinition parafld in rpt.DataDefinition.Paramet<wbr ></wbr>erFields)
            {
                if (parafld.DiscreteOrRangeKi<wbr ></wbr>nd.ToStrin<wbr ></wbr>g() == "test")
                {
                    discreteVal.Value = Request.QueryString[parafl<wbr ></wbr>d.Paramete<wbr ></wbr>rFieldName<wbr ></wbr>];
                    if (discreteVal.Value != null)
                    {
                        curvalues.Add(discreteVal)<wbr ></wbr>; parafld.ApplyCurrentValues<wbr ></wbr>(curvalues<wbr ></wbr>);
                    }
                }
            }

            myConnectionInfo.ServerNam<wbr ></wbr>e = ".\\sqlexpress";
            myConnectionInfo.DatabaseN<wbr ></wbr>ame = "studytimetrackerprime";
            myConnectionInfo.UserID = "mydbUserID";
            myConnectionInfo.Password = "********";
            setDBLOGONforREPORT(myConn<wbr ></wbr>ectionInfo<wbr ></wbr>); 

            //FillWeeklyLogRpt(rpt);

            RepointReport(rpt, Conn);
            Session["REP"] = rpt;
            report = rpt;
        }
        else
        {
            report = (ReportDocument)Session["R<wbr ></wbr>EP"];
        }

        CrystalReportViewer1.Repor<wbr ></wbr>tSource = report;
    }

Open in new window

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 39192329
Yes you need to use the parameter in the record selection
Probably something like

{YourField} = {?Parameter}


When you click OK on the error what happens?
Do you get placed in the code or does a formula in the report open?

mlmcc
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 39192372
with the debugger on it does put me in the code, but it doesn't error out anywhere in the code. with it off, nothing opens. i have set that formula up. i placed it in the report header (in the designer). still nothing has changed. is there another place i should've put it?

crystal formula
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 39192400
In the report
Click REPORT --> SELECTION FORMULA --> RECORD

Add the formula there

mlmcc
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 39192518
i think what its come down to is that there is a lot of inconsistent behavior. sometimes it won't prompt for anything after an initial rendering (and prompting of the database credentials) of the page. it often prompts for the database log on which i've set to disabled in the html, so i don't quite understand that. the parameter pane, when its available doesn't allow for me to change the parameter. i think i'm gonna have to create custom pages for each variation of the report unfortunately. i just can't seem to get this thing to give me any stable results or behavior. i must be missing something major about how i have my report written or the viewer set up / configured.
0
 
LVL 1

Author Closing Comment

by:mikesExpertExchange
ID: 39428220
thank you. also i am still getting help from you with this topic in another question
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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