Hasibul Haque

Hasibul Haque hasibul

Niner since 2010

Comments

  • Looking at the Report Viewer Control

    Thanks for wonderful post. It helps me for creating rdlc report.

    Now i need another help.

    I need to add two tables/procedures in my report.

     

    My report have two section. One is Header and another is details.

     

    I sgall use companyInfo table for header and use TransactionInfo for detail section.

     

    But i am unable to add two table of data Programmatically.

     

    The report talke only one table with specific datasource name.

    How i can load twho table at a time.

    consider following code which i have used for retriveing single data table.

     

     

    string sqlQ = "Select * from CompanyInfo";
                string sqlQ1= @"Select * from command_1 where operationType = 2";


                DataSet ds = new DataSet() ;
                SqlConnection con = new SqlConnection("Data Source=ITSOFT206; initial catalog=rbrl;user id = sa;password=start777");
                con.Open();

                DataTable dt = new DataTable();
                DataTable dt1 = new DataTable();

                SqlDataAdapter da = new SqlDataAdapter(sqlQ , con);
                SqlDataAdapter da1 = new SqlDataAdapter(sqlQ1, con);

                da.Fill(dt);
                da1.Fill(dt1);
                dt.TableName = "CompanyInfo";
                dt1.TableName = "command_1";
                ds.Tables.Add(dt.Copy ());
                ds.Tables.Add(dt1.Copy());
                da.Dispose();
                da1.Dispose();
                con.Close();

                
                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                LocalReport lc = ReportViewer1.LocalReport;
                lc.ReportPath = "Report1.rdlc";



                ReportDataSource rds = new ReportDataSource();
                rds.Name = "rptSource_command_1";
                
               
                rds.Value = ds.Tables["command_1"];


                 lc.DataSources.Add (rds);

                 ReportViewer1.LocalReport.DataSources.Clear();
                 ReportViewer1.LocalReport.DataSources.Add(rds);
                 ReportViewer1.LocalReport.Refresh();

     

    hope i will get solution.