Working with crystlreport in vs2008 ,have created two paramers fields using designer and
also generated formula in formula editor :
{cashtbl.StdID} = {?stdid} or{cashtbl.ExamId} = {?examid}
I have written code on buttonclick events to see values as per stdid or examid parametrfields mapped it with two textboxes,from cashtbl
the code gives error at runtime when selecting examid from textbox2:The types of the parameter field and parameter field current values are not compatible.
my code in button is:

ParameterFieldDefinitions parafields1;
            ParameterFieldDefinition parafeild1;
            ParameterFieldDefinitions parafields2;
            ParameterFieldDefinition parafeild2;
            ParameterValues values1 = new ParameterValues();
            ParameterValues values2 = new ParameterValues();
            ParameterDiscreteValue discretevalue1 = new ParameterDiscreteValue();
            ParameterDiscreteValue discretevalue2 = new ParameterDiscreteValue();
            discretevalue1.Value = textBox1.Text;
            discretevalue2.Value = textBox2.Text;
            parafields1 = crystalReport11.DataDefinition.ParameterFields;
            parafeild1 = parafields1["stdid"];
            values1 = parafeild1.CurrentValues;
            values1.Clear();
            values1.Add(discretevalue1);
            parafeild1.ApplyCurrentValues(values1);
             parafields2 = crystalReport11.DataDefinition.ParameterFields;
            parafeild2 = parafields2["examid"];
            values2 = parafeild2.CurrentValues;
            values2.Clear();
            values2.Add(discretevalue2);
            parafeild2.ApplyCurrentValues(values2);
            crystalReportViewer1.ReportSource = crystalReport11;
            crystalReportViewer1.Refresh();

why is not showing records as per second parameter i.e examid?
pls help

mani-hellboy commented: give aprapriate code -1

Your code is really confusing. But I suspect that your error is caused by setting a string to an number or vice versa. Determine the data types of all those fields (maybe give them more meaningful names too). Compare these types to what you are providing them - in this case it looks like the 2 values are coming in as strings from 2 textboxes. Make sure both stid and examid are being passed numbers (probably int32s) rather than strings (the .Text field of a textbox) if they are in fact numeric datatypes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.