我处于非常复杂的情况之间。我只从一个只需要一个参数的存储过程填充一条记录并根据它选择记录,例如, @complaintCode。现在需求已经改变,它应该加载多个记录,即,我有两个日期文本框,它们只选择落在这些日期之间的投诉代码,例如20个投诉代码,现在我的rdlc应显示已加载到数据集中的所有投诉代码的所有记录。从数据集中加载rdlc中的多条记录
为了让我的问题变得简单: 1.输入2个日期并点击搜索,它会在日期范围之间加载许多投诉代码并放入数据集。 2.现在我想填写存储过程中的数据集,它只接受一个参数,即投诉代码并将所有记录加载到rdlc报告中,如何?
代码:
protected void btnGenReport_Click(object sender, EventArgs e)
{
try
{
DateTime fromDate = DateTime.ParseExact(txtFromDate.Text, "dd/MMM/yyyy", null);
DateTime toDate = DateTime.ParseExact(txtToDate.Text, "dd/MMM/yyyy", null);
DataTable dt_temp = MyComplaints.SearchAllComplaintByDate(fromDate, toDate);
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/Report_Complaints24Hours_Sdpo.rdlc");
string ComplaintCode = Convert.ToString(txtComplaintCode.Text);
DataTable dt = ManageRecievedMessage.Report_Complaints24Hours_Sdpo(ComplaintCode);
if (dt.Rows.Count <= 0)
{
HiddenFieldSetMessage.Value = "WrongDatesComb";
HiddenFieldShowMessage.Value = "True";
ReportViewer1.Visible = false;
}
else
{
ReportDataSource rpds = new ReportDataSource("DataSet1", dt);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rpds);
ReportViewer1.Visible = true;
}
}
谢谢很多先生,但我的问题不是这个,问题是,我从另一个表加载ComplaintCode然后通过这些代码1加载另一个记录另一个表 – user3518032 2014-08-28 11:43:53
为什么每次都要传递一个值你可以在sql查询中使用“in”关键字 Like select ... from ... where id in(--your all values--) – yogi970 2014-08-28 11:48:50
这很简单在sql查询中使用“in”。尝试在声明中使用。 :)希望它能解决你的问题 – yogi970 2014-08-28 11:50:17