Hi Friend, Today we will learn"How to pass parameter in Crystal reports and fetch the records from the sql database on behalf of parameter pass in text box".Suppose, you have many records in your database and want to sort the records then you have to sort the records on the basis of any one column value in your database.Here we will pass this parameter value in crystal reports and display the sorted records in crystal reports.then you can download or print this records from the crystal reports. In previous post, you have learned as following.
There are some steps to implements this whole concepts as given below:-Step 1:- First Create Crystal reports from Here (Follow step 1 to step 9 only).
Note:-Here,i have used Student1 table instead of employee table as shown below:-
Step 2:- After performed step 1 ,you will see following output as shown below:-
Step 3:- Now Right click on Parameter fields --> new --> Now Write Name of parameter,Select its Type,Select ValueField and select Description Field as shown below -->OK
Step 4:- Now open Parameter Fields -->Select City --> Press Select Expert -->and select Required fields as shown below:-
Step 5:-Now Open Solution Explorer-->Open Default.aspx --> Press Smart Tag Right hand side of Crystal Reports Viewer --> Select Choose a Tool Panel view (ParameterPanel) and Unchecked three checked boxes as shown below:-
Step 6:- Now open Default.aspx page--> Drag and Drop one Text Box and Button Controls from the Toolbox as shown below:-
Step 7:-Now open Default.aspx.cs file -->Write the c# codes on Proceed Button"s click to access the database records with the help of parameter value City as given below:-
using System;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
ReportDocument report1 = new ReportDocument();
report1.Load(Server.MapPath("CrystalReport1.rpt"));
report1.SetDatabaseLogon("","","RAMASHANKAR-PC","master");
report1.SetParameterValue("City",TextBox1.Text);
CrystalReportViewer1.ReportSource = report1;
}
}
Descriptions:-report1.SetDatabaseLogon("","","RAMASHANKAR-PC","master")
Here this method takes four parameters.
- User Name
- Password
- Server Name
- Database Name
Step 8:- Now Run the application (press F5) --> Now write City Name in Text Box -->Press proceed Button as shown below:-
For More...
- How to Add Database .mdf file in asp.net website
- How to implement 3 tier architecture with real life example
- How to insert data in database and print the Gridview data in windows forms application
- How to take print receipt of windows forms application
- Call by value and call by reference
- File Handling Real concepts
- How to make form filling application like IBPS
- How to create a calculator application and install it to others computer
- How to import excel file data in database and display it in Gridview control
- C# Language with Real life Examples
- ASP.NET With Real life Examples
- ADO.NET With Real life Examples
- SQL Server with Real implementation
- Complete LINQ Concepts with Examples
- Ajax Concepts with Examples
- Complete WCF Concepts with Real Examples
- Web services with Real life Examples
- ASP.NET MCV Concepts with examples
Download
0 comments:
Post a Comment