public void Read() { SqlConnection conn = new SqlConnection(this.connectionString); SqlCommand comm = new SqlCommand("SELECT *FROM TbProductName ORDER BY ProductName", conn); SqlDataAdapter adap = new SqlDataAdapter(); DataSets.StockDataSet dataset = new DataSets.StockDataSet(); StockCrystalReport crp = new StockCrystalReport(); try { conn.Open(); adap.SelectCommand = comm; adap.Fill(dataset, "DataTable1"); crp.SetDataSource(dataset); crystalReportViewer2.ReportSource = crp; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } finally { conn.Close(); } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { StockCrystalReport rpt = new StockCrystalReport(); rpt.Site = this.Site; return rpt; }