打印按鈕的代碼如下,但是處理完后crystalReportViewer的對(duì)象打印預(yù)覽只是一片空白,ds.table[0]顯示沒有數(shù)據(jù),不知為何數(shù)據(jù)獲取不了,請(qǐng)問如何解決呢
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 車牌號(hào),car_type 車型,students_num 預(yù)約人數(shù),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]);//設(shè)置報(bào)表頁面數(shù)據(jù)源 frm_print.crystalReportViewer1.ReportSource = rpt1; cn.Close(); cmd.Dispose(); frm_print.Show(); }
crystalReportViewer打印預(yù)覽為空白
月關(guān)寶盒
2018-12-07 07:28:24