Crystal Report with parameters
In this code snippet, you will see how to create a Crystal Report with parameters support.
- Create a form with a label, Button and a Textbox for entring user id that you want to print report add a crystal report viewer control to the form to show Report
- Now add a CrystalRerpot form by adding New item (Choose Blank report form the wizard)
- Attach a table with this report form filed explorer in crystal report by right click on data connections
- insert fileds of table on Reprot detail section from the field section
- now click the button on form1 that having crystal report viewer control
- in button coading paste the following code in button clicking.
private void button1_Click(object sender, EventArgs e)
{
Employee obj = new Employee(); //Object of Crystal Report
obj.SetParameterValue("p1", int.Parse(textBox1.Text)); //Providing value to crystal report parameter
crystalReportViewer1.ReportSource = obj; //assigning crystal report object to crystal report viewer
}
Note:- zip file enclosed with this post contain a .doc file conatian all procedure in detail.
Pardeep Malik