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

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?
LVL 1
Michael SterlingWeb Applications DeveloperAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mlmccConnect With a Mentor Commented:
In the report
Click REPORT --> SELECTION FORMULA --> RECORD

Add the formula there

mlmcc
0
 
mlmccCommented:
How did you create the parameter?

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

mlmcc
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Michael SterlingWeb Applications DeveloperAuthor Commented:
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
 
mlmccCommented:
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
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
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
 
mlmccCommented:
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
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
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
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
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
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
thank you. also i am still getting help from you with this topic in another question
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.