日期:2014-05-17 浏览次数:20570 次
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.Load(Application.StartupPath + "CrystalReport1.rpt"); rpt1.SetDataSource( ds.Tables[0]);//设置报表页面数据源 frm_print.crystalReportViewer1.ReportSource = rpt1; cn.Close(); cmd.Dispose(); frm_print.Show(); }