Я пытаюсь передать набор данных в качестве источника данных для отчета, который я хочу просмотреть с помощью Microsft Reporting Control, размещенного в форме winform.Я использую следующий код для этой цели, но не смог выполнить задачу.
private void Form1_Load(object sender, EventArgs e)
{
// Sql Connection Object
SqlConnection con = new SqlConnection(@"Data Source=SEVEN01-PC\SQLEXPRESS;Initial Catalog=RealWorld;Integrated Security=SSPI;");
// Sql Command Object
SqlCommand cmd = new SqlCommand("Select * from ProductReorder", con);
try
{
// Open Connection
con.Open();
// Dataset Object
DataSet ds = new DataSet();
// Sql DataReader Object
SqlDataReader reader = cmd.ExecuteReader();
// Fill Data Set
ds.Tables[0].Load(reader);
// Close Sql Datareader and Connection Objects
reader.Close();
con.Close();
//provide local report information to viewer
reportViewer1.LocalReport.ReportEmbeddedResource = "ProductReorder.rptProductReorder.rdlc";
//prepare report data source
ReportDataSource rds = new ReportDataSource();
rds.Name = "dsProductReorder_dtProductReorder";
rds.Value = ds.Tables[0];
reportViewer1.LocalReport.DataSources.Add(rds);
//load report viewer
this.reportViewer1.RefreshReport();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Любые предложения по назначению набора данных для источника данных отчета!