Quantcast
Channel: Crystal Reports
Viewing all articles
Browse latest Browse all 1507

Pass Multiple Parameters to Crystal report.

$
0
0

Hai,

I'm New to Crystal Report Creation.

I'm using VS2010 and SQL Server 2005.

I have created a Crystal report for my Salary Slip Creation project with the help of the URL

http://www.youtube.com/watch?v=TIcwNrUKV30&hd=1

Its run successfully. But I have some more conditions to satisfy.

See My code below:

 

protected void Page_Load(object sender, EventArgs e)

//Here I retreive Employee ID into DropDownListBox from database
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection("Data Source=SERVICETEAM-PC;Initial Catalog=salaryReg;User ID=sa;Password=kavi");
con.Open();
SqlCommand com = new SqlCommand("select empID from SalaryEarnings ", con);
SqlDataReader dr = com.ExecuteReader(); ;

DropDownList1.Items.Clear();
while (dr.Read())
{
DropDownList1.Items.Add(new ListItem(dr[0].ToString()));
}
DropDownList1.Items.Insert(0, new ListItem("--Select--", "0"));
con.Close();
}

}
protected void btnDisplay_Click(object sender, EventArgs e)
{
ReportDocument rdoc = new ReportDocument();
SqlConnection con = new SqlConnection("Data Source=SERVICETEAM-PC;Initial Catalog=salaryReg;User ID=sa;Password=kavi");
con.Open();
SqlCommand cmd = new SqlCommand("SalaryEarnings1",con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
rdoc.Load(Server.MapPath("CrystalReport.rpt"));
rdoc.SetDataSource(dt);
rdoc.SetParameterValue("empid", DropDownList1.Text);
CrystalReportViewer1.ReportSource = rdoc;
CrystalReportViewer1.DataBind();
con.Close();
}

By the above code, I select an Employee ID from the DropDownList and press the Display button. Its successfully display the record of that particular Employee ID.

But I need to satisfy another two conditions like Month and year. At the Execution time the user need to select Employee ID, Month and year from DropDownList Boxes. The Crystal Report should display only for that particular record.

If you know the solution please Reply the answer to me.....


Viewing all articles
Browse latest Browse all 1507

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>