我處於非常複雜的情況之間。我只從一個只需要一個參數的存儲過程填充一條記錄並根據它選擇記錄,例如, @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