打印按钮的代码如下,但是处理完后crystalReportViewer的对象打印预览只是一片空白,ds.table[0]显示没有数据,不知为何数据获取不了,请问如何解决呢
private void button1_Click_1(object sender, EventArgs e)
{
Form_ClystylePrint frm_print = new Form_ClystylePrint();
MyData mydata = new MyData();
SqlConnection cn = mydata.getConn();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cn.Open();
cmd.CommandText = "select examiner 考官,car_shool 驾校,car 车牌号,car_type 车型,students_num 预约人数,table_maker 制表人 from Arrange_Table where exam_date = getdate()";
SqlDataAdapter sda = new SqlDataAdapter(cmd.CommandText, cn);
DataSet ds = new DataSet();
sda.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
CrystalReport1 rpt1 = new CrystalReport1();
rpt1.SetDataSource( ds.Tables[0]);//设置报表页面数据源
frm_print.crystalReportViewer1.ReportSource = rpt1;
cn.Close();
cmd.Dispose();
frm_print.Show();
}
湖上湖
慕村225694