Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There are 2 tables sale & sale1 I want to display data from these two table in one crystal report.

C#
        DataReportClass dr = new DataReportClass();
        DataView dview1 = new DataView();
        sale s = new sale();
        String qry, tname = "sale",tname1="sale1";
        //form load
        private void rpt_sale_Load(object sender, EventArgs e)
        {
            dview1.Table = dr.LoadReport1(tname,tname1).Tables["Temp"];
            s.SetDataSource(dview1);
            crystalReportViewer1.ReportSource = s;
        }
      //This code is in my .class file
       public DataSet LoadReport1(String tablename,String tbl)
       {
           qry = "Select * from " + tablename + ","+tbl+"";
           ds = db.search(qry);
//db is object of my another .class file includes connection string
           return ds;
       }

        public DataSet search(String s)
        {
            try
            {
                SqlDataAdapter da = new SqlDataAdapter(s, conn);
                DataSet ds = new DataSet();
                da.Fill(ds, "Temp");
                return ds;
            }
            catch(Exception ex)
            {
                throw ex;
            }
         }
Posted
Updated 25-Jan-15 2:07am
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900