private void MyReport_Load(object sender, EventArgs e) { ReportDocument rptDoc = new ReportDocument(); FileDataSet1 ds = new FileDataSet1(); // .xsd file name DataTable dt = new DataTable(); dt.TableName = "Crystal Report Example"; dt = getAllOrders(); //This function is located below this function ds.Tables[0].Merge(dt); try { string rPath = Directory.GetCurrentDirectory(); int index = rPath.ToLower().IndexOf("bin"); if (index >= 0) { rPath = rPath.Substring(0, index); } rPath = rPath + @"FileMenu\CrystalReport2.rpt"; rptDoc.Load(rPath); rptDoc.SetDataSource(ds); crystalReportViewer1.ReportSource = rptDoc; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } public DataTable getAllOrders() { string sqlCon = "....."; SqlConnection Con = new SqlConnection(sqlCon); SqlCommand cmd = new SqlCommand(); DataSet ds = null; SqlDataAdapter adapter; try { Con.Open(); cmd.CommandText = "select * from Account_Details"; cmd.Connection = Con; ds = new System.Data.DataSet(); adapter = new SqlDataAdapter(cmd); adapter.Fill(ds, "Users"); } catch (Exception ex) { throw new Exception(ex.Message); } finally { cmd.Dispose(); if (Con.State != ConnectionState.Closed) Con.Close(); } return ds.Tables[0]; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)