I have a stored procedure that will be used to create a report in reportviewer (the one supplied within VS2010). There are 4 parameters - Start Date, End Date - single parameters. Multi-value parameters - Status (6 possible choices), Location(250 possible choices).
I'm unable to determine the proper way to code it so that the report will show all items within the date range, for the various status/locations requested.
For example: Show me all parts between (start date) 7/1/2012 AND (end date) 9/3/2012 that are from (location) Hazleton or Butler and are (status)Available or Out.
The code to call the stored procedure:
public DataTable StatusRpt(DateTime StartDate, DateTime EndDate)
{
SQLCON = new SqlConnection(connectionString);
SQLCON.Open();
SQLCommand = new SqlCommand("spStatusRpt",SQLCON);
SQLCommand.CommandType = CommandType.Text;
SQLCommand.Parameters.Add("@StartDate", SqlDbType.Date).Value = StartDate;
SQLCommand.Parameters.Add("@EndDate", SqlDbType.Date).Value = EndDate;
//SQLCommand.Parameters.Add("@Status", SqlDbType.Int).Value = Status;
//SQLCommand.Parameters.Add("@OrgName", SqlDbType.VarChar).Value = OrgName;
SqlDataAdapter adapter = new SqlDataAdapter(SQLCommand);
DataTable Detailtable = new DataTable();
adapter.Fill(Detailtable);
return Detailtable;
}
And here's my "onClick" event
protected void btnStatusReport_OnClick(object sender, EventArgs e)
{
int Status = Convert.ToInt32(lbxStatus.SelectedValue);
string OrgName = lbxLocations.SelectedValue;
DateTime StartDate = Convert.ToDateTime(CalStart.SelectedDate);
DateTime EndDate = Convert.ToDateTime(CalEnd.SelectedDate);
lblPrint.Visible = true;
DataTable DetailTable = equip.StatusRpt(StartDate, EndDate);
this.RV1.Reset();
this.RV1.LocalReport.DataSources.Clear();
this.RV1.LocalReport.ReportPath = "Reports/StatusReport.rdlc";
ReportDataSource rds = new ReportDataSource("StatusDS", DetailTable);
this.RV1.LocalReport.DataSources.Add(rds);
this.RV1.DataBind();
}
I've done some research, but everything I've found refers to using SSRS. I'm ok with filtering, if someone can show me how to apply the filter via code.
Thank you in advance for any and all assistance. Cindy