我使用了一个DataSet控件,命名为PrintDs,在PrintDs中有一个PrintDt(DataTable),并进行如下数据绑定,结果DataGridView可以显示数据,而ReportViewer不能显示数据,代码如下,请高人指点。在下万分感激。
private void Form2_Load(object sender, EventArgs e)
{
string Sql = "SELECT OrderID, CustomerID FROM Orders";
SqlDataAdapter da = new SqlDataAdapter(Sql, Sqlstr.GetCon());
PringDs ds = new PringDs();
da.Fill(ds, "PrintDt");
dataGridView1.DataSource = ds.Tables[0];
//ReportDataSource rds = new ReportDataSource("PrintDt", ds.Tables[0]);
//reportViewer1.LocalReport.DataSources.Clear();
//reportViewer1.LocalReport.DataSources.Add(rds);
//this.reportViewer1.RefreshReport();
}