1
我使用ReportViewer控件設計報表,但是當我運行該項目,我得到這個錯誤:的ReportViewer RDL文件
A data source instance has not been supplied for the data source 'DataSet1'.
這裏是我的代碼:
SqlConnection myConnection = new SqlConnection();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter sqla = new SqlDataAdapter();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
myConnection.ConnectionString = SqlDataSource1.ConnectionString;
cmd.Connection = myConnection;
cmd.CommandText ="select * from users";
cmd.CommandType = CommandType.Text;
sqla.SelectCommand = cmd;
sqla.Fill(dt);
sqla.Fill(ds);
ReportViewer1.Reset();
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.Visible = true;
ReportViewer1.LocalReport.ReportPath = "reports/allusers.rdl";
ReportDataSource rds = new ReportDataSource("ds_users",dt);
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.ZoomMode = ZoomMode.Percent;
ReportViewer1.LocalReport.Refresh();
什麼時我錯過了?
你可以接受你自己的答案。 – 2013-03-12 18:53:09
直到2天之後,如果它不是問答形式。 – Shelby115 2013-03-13 18:06:13