我在我的 winform 中编写了这段代码以在 CrystalReportviewer 中显示 my_table 内容,但没有显示任何内容:
private void Form10_Load(object sender, EventArgs e)
{
String connString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\bank.mdf;Integrated Security=True;User Instance=True";
SqlConnection conn = new SqlConnection(connString);
SqlDataAdapter da = new SqlDataAdapter("SELECT * from my_table", conn);
DataTable dt = new DataTable();
da.Fill(dt);
ReportDocument rd = new ReportDocument();
rd.Load("CrystalReport2.rpt");
rd.SetDataSource(dt);
crystalReportViewer1.ReportSource = rd;
crystalReportViewer1.Show();
}
问题是什么?