private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor         = Cursors.WaitCursor;
         timer1.Enabled = true;
         rptCustomers rpt = new rptCustomers();
         //The report you created.
         cmd = new OleDbCommand();
         OleDbDataAdapter myDA = new OleDbDataAdapter();
         SIS_DBDataSet    myDS = new SIS_DBDataSet();
         //The DataSet you created.
         con                = new OleDbConnection(cs);
         cmd.Connection     = con;
         cmd.CommandText    = "SELECT * from Customer order by CustomerName";
         cmd.CommandType    = CommandType.Text;
         myDA.SelectCommand = cmd;
         myDA.Fill(myDS, "Customer");
         rpt.SetDataSource(myDS);
         frmCustomersReport frm = new frmCustomersReport();
         frm.crystalReportViewer1.ReportSource = rpt;
         frm.Visible = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor         = Cursors.WaitCursor;
         timer1.Enabled = true;
         rptCustomers rpt = new rptCustomers();
         //The report you created.
         frmCustomersReport frm          = new frmCustomersReport();
         SqlConnection      myConnection = default(SqlConnection);
         SqlCommand         MyCommand    = new SqlCommand();
         SqlDataAdapter     myDA         = new SqlDataAdapter();
         POS_DBDataSet      myDS         = new POS_DBDataSet();
         //The DataSet you created.
         myConnection          = new SqlConnection(cs.DBConn);
         MyCommand.Connection  = myConnection;
         MyCommand.CommandText = "select * from Customer Order by CustomerName";
         MyCommand.CommandType = CommandType.Text;
         myDA.SelectCommand    = MyCommand;
         myDA.Fill(myDS, "Customer");
         rpt.SetDataSource(myDS);
         frm.crystalReportViewer1.ReportSource = rpt;
         frm.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }