我的数据gridview
确实有效但rdlc
报告没有显示任何内容。
我有report.rdlc
个文件和dataset(DataSet1)
,其中包含datatable(DataTable1)
。我的数据表有两列Wname
和Ccode
,它们都是string
:
SqlConnection scon = new SqlConnection(@"data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\PCPdb.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True");
string query = "SELECT Wname,Ccode FROM tbl_Worker wk inner join tbl_Contract cont on wk.Wcode=cont.CWcode WHERE wk.Wcode=1122";
DataTable dt = new DataTable();
dt.TableName = "DataTable1";
SqlCommand scm = new SqlCommand(query, scon);
SqlDataAdapter sda = new SqlDataAdapter(scm);
scon.Open();
scm.ExecuteNonQuery();
sda.Fill(dt);
dataGridView1.DataSource = dt;
ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSet1";
rds.Value = dt;
reportViewer1.LocalReport.DataSources.Add(rds);
this.reportViewer1.RefreshReport();
scon.Close();