我有一个存储过程,将用于在 reportviewer(VS2010 中提供的那个)中创建报告。有 4 个参数 - 开始日期、结束日期 - 单个参数。多值参数 - 状态(6 个可能的选择)、位置(250 个可能的选择)。
我无法确定对其进行编码的正确方法,以便报告将显示日期范围内的所有项目,用于请求的各种状态/位置。
例如:显示(开始日期)2012 年 7 月 1 日和(结束日期)2012 年 9 月 3 日之间来自(位置)Hazleton 或 Butler 并且(状态)可用或已售出的所有部件。
调用存储过程的代码:
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;
}
这是我的“onClick”事件
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();
}
我做了一些研究,但我发现的一切都是指使用 SSRS。如果有人可以告诉我如何通过代码应用过滤器,我可以过滤。
提前感谢您的任何和所有帮助。辛迪