Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. in microsoft report viewer i want change datasource in run time

in microsoft report viewer i want change datasource in run time

Scheduled Pinned Locked Moved C#
design
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nabawoka
    wrote on last edited by
    #1

    i add data set & add 4 table in this data set and design 4 reports for each table i want to choose the report & set datasource to report and show in microsoft report view i try this code but failed

       ReportOfEng.LocalReport.ReportEmbeddedResource = "follow\_up.Report1.rdlc";
            ReportDataSource ds = new ReportDataSource();
            ds.Name = dataSet11.Movements.TableName;
            ds.Value = dataSet11.Movements;
            ReportOfEng.LocalReport.DataSources.Clear();
            ReportOfEng.LocalReport.DataSources.Add(ds);
            this.movementsTableAdapter1.Fill(dataSet11.Movements);
            this.ReportOfEng.RefreshReport();
    

    then in runtime when i btnclick this message appear in report "data source instance has not been supplied for dataset" so what i can do :-D

    P N 2 Replies Last reply
    0
    • N Nabawoka

      i add data set & add 4 table in this data set and design 4 reports for each table i want to choose the report & set datasource to report and show in microsoft report view i try this code but failed

         ReportOfEng.LocalReport.ReportEmbeddedResource = "follow\_up.Report1.rdlc";
              ReportDataSource ds = new ReportDataSource();
              ds.Name = dataSet11.Movements.TableName;
              ds.Value = dataSet11.Movements;
              ReportOfEng.LocalReport.DataSources.Clear();
              ReportOfEng.LocalReport.DataSources.Add(ds);
              this.movementsTableAdapter1.Fill(dataSet11.Movements);
              this.ReportOfEng.RefreshReport();
      

      then in runtime when i btnclick this message appear in report "data source instance has not been supplied for dataset" so what i can do :-D

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Well, LocalReport.DataSources has been cleared, and yet you haven't done a LocalReport.DataSources.Add.

      I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

      Forgive your enemies - it messes with their heads

      My blog | My articles | MoXAML PowerToys | Onyx

      N 1 Reply Last reply
      0
      • P Pete OHanlon

        Well, LocalReport.DataSources has been cleared, and yet you haven't done a LocalReport.DataSources.Add.

        I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

        Forgive your enemies - it messes with their heads

        My blog | My articles | MoXAML PowerToys | Onyx

        N Offline
        N Offline
        Nabawoka
        wrote on last edited by
        #3

        i add the datasource in program but i forget to add in this block code ;) so the error appear in the report so again what can i do :-D

        1 Reply Last reply
        0
        • N Nabawoka

          i add data set & add 4 table in this data set and design 4 reports for each table i want to choose the report & set datasource to report and show in microsoft report view i try this code but failed

             ReportOfEng.LocalReport.ReportEmbeddedResource = "follow\_up.Report1.rdlc";
                  ReportDataSource ds = new ReportDataSource();
                  ds.Name = dataSet11.Movements.TableName;
                  ds.Value = dataSet11.Movements;
                  ReportOfEng.LocalReport.DataSources.Clear();
                  ReportOfEng.LocalReport.DataSources.Add(ds);
                  this.movementsTableAdapter1.Fill(dataSet11.Movements);
                  this.ReportOfEng.RefreshReport();
          

          then in runtime when i btnclick this message appear in report "data source instance has not been supplied for dataset" so what i can do :-D

          N Offline
          N Offline
          Nabawoka
          wrote on last edited by
          #4

          depend on RadioButton Check :-D

                  if (rdbEng.Checked==true)
                  {
                      ReportsOfRun.Reset();
                      ReportsOfRun.LocalReport.ReportEmbeddedResource = "follow\_up.Report\_Eng.rdlc";
                      ds.Name = "DataSetReport\_Eng\_Table";
                      ds.Value = Eng\_TableBindingSource;
                      //ReportsOfRun.LocalReport.DataSources.Clear();
                      ReportsOfRun.LocalReport.DataSources.Add(ds);
                      ReportsOfRun.DocumentMapCollapsed = true;
                      this.Eng\_TableTableAdapter.Fill(this.DataSetReport.Eng\_Table,int.Parse(txtEngCode.Text)); 
                  }
                  else if (rdbMonth.Checked==true)
                  {
                      ReportsOfRun.Reset();
                      ReportsOfRun.LocalReport.ReportEmbeddedResource = "follow\_up.Report\_Month.rdlc";
                      ds.Name = "DataSetReport\_Month\_Table";
                      ds.Value = Month\_TableBindingSource;
                      //ReportsOfRun.LocalReport.DataSources.Clear();
                      ReportsOfRun.LocalReport.DataSources.Add(ds);
                      ReportsOfRun.DocumentMapCollapsed = true;
                     this.Month\_TableTableAdapter.Fill(this.DataSetReport.Month\_Table, txtMonth.Text);
                  }
          

          thanx to how try to help me

          P 1 Reply Last reply
          0
          • N Nabawoka

            depend on RadioButton Check :-D

                    if (rdbEng.Checked==true)
                    {
                        ReportsOfRun.Reset();
                        ReportsOfRun.LocalReport.ReportEmbeddedResource = "follow\_up.Report\_Eng.rdlc";
                        ds.Name = "DataSetReport\_Eng\_Table";
                        ds.Value = Eng\_TableBindingSource;
                        //ReportsOfRun.LocalReport.DataSources.Clear();
                        ReportsOfRun.LocalReport.DataSources.Add(ds);
                        ReportsOfRun.DocumentMapCollapsed = true;
                        this.Eng\_TableTableAdapter.Fill(this.DataSetReport.Eng\_Table,int.Parse(txtEngCode.Text)); 
                    }
                    else if (rdbMonth.Checked==true)
                    {
                        ReportsOfRun.Reset();
                        ReportsOfRun.LocalReport.ReportEmbeddedResource = "follow\_up.Report\_Month.rdlc";
                        ds.Name = "DataSetReport\_Month\_Table";
                        ds.Value = Month\_TableBindingSource;
                        //ReportsOfRun.LocalReport.DataSources.Clear();
                        ReportsOfRun.LocalReport.DataSources.Add(ds);
                        ReportsOfRun.DocumentMapCollapsed = true;
                       this.Month\_TableTableAdapter.Fill(this.DataSetReport.Month\_Table, txtMonth.Text);
                    }
            

            thanx to how try to help me

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            Well done, and well done for showing your solution. That's a bit of class that is. :-D

            I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

            Forgive your enemies - it messes with their heads

            My blog | My articles | MoXAML PowerToys | Onyx

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups