我有一个学生列表,我想为每个正在使用SQL storageProcedure获取数据和Crystal Reports的学生打印费用清单。我想做的是,打开所有ReportViewer
并传递所有studentIds
并在预览部分显示它们。
我做到了:
ReportDocument rd = new ReportDocument();
private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
{
rd.Load(@"C:\\Program Files (x86)\CognitiveDev\TKS Management System\Reports\FeeSlip.rpt");
try
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["Other"].ConnectionString;
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter("PrintFeeSlip", conn);
sda.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
foreach (int gotId in gotList)
{
sda.SelectCommand.Parameters.AddWithValue("@AdmissionNumber", gotId);
DataSet ds = new DataSet();
sda.Fill(ds, "FeeSlip");
rd.SetDataSource(ds);
reportView.ViewerCore.ReportSource = rd;
reportView.ViewerCore.RefreshReport();
}
}
catch (Exception err)
{
MessageBox.Show(err.ToString());
}
}
此代码仅适用于单个代码,但多个stdID
应该怎么办