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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Microsoft Reportviewer question

Microsoft Reportviewer question

Scheduled Pinned Locked Moved C#
questionxmltutorialworkspace
2 Posts 1 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.
  • R Offline
    R Offline
    Rafone
    wrote on last edited by
    #1

    Can somebody tell me why this code is not working. It keeps saying "A datasource instance has not has not been supplied for the data source. Also I have scoured the web for some good documentation on how to set these up on the fly but I have not found any great info. Can somebody point me in the right direction? private void toolStripButton1_Click_1(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; try { // Set Processing Mode reportViewer1.ProcessingMode = ProcessingMode.Local; // Set RDL file reportViewer1.LocalReport.ReportPath = (Application.StartupPath + "\\reports\\trdReport.rdlc"); // Supply a DataTable corresponding to each report data source reportViewer1.LocalReport.DataSources.Add( new ReportDataSource("getTrends", LoadData())); // Add the reportviewer to the form reportViewer1.Dock = DockStyle.Fill; // Process and render the report reportViewer1.RefreshReport(); } catch (Exception ex) { StreamWriter writer = new StreamWriter(logFile, true, System.Text.Encoding.ASCII); writer.WriteLine(System.DateTime.Now); writer.WriteLine("[generate report]"); writer.WriteLine("[generate report]"); writer.WriteLine(ex); writer.WriteLine("\r"); writer.Close(); MessageBox.Show(ex.ToString()); //this.Close(); //System.Environment.Exit(0); } this.Cursor = Cursors.Default; } private DataTable LoadData() { // Load data from XML file DataSet ds = new DataSet(); string myFilePath = (Application.StartupPath + "\\bin\\" + "trd.xml"); ds.ReadXml(myFilePath); return ds.Tables[0]; } tia rafone Statistics are like bikini's... What they reveal is astonishing ... But what they hide is vital ...

    R 1 Reply Last reply
    0
    • R Rafone

      Can somebody tell me why this code is not working. It keeps saying "A datasource instance has not has not been supplied for the data source. Also I have scoured the web for some good documentation on how to set these up on the fly but I have not found any great info. Can somebody point me in the right direction? private void toolStripButton1_Click_1(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; try { // Set Processing Mode reportViewer1.ProcessingMode = ProcessingMode.Local; // Set RDL file reportViewer1.LocalReport.ReportPath = (Application.StartupPath + "\\reports\\trdReport.rdlc"); // Supply a DataTable corresponding to each report data source reportViewer1.LocalReport.DataSources.Add( new ReportDataSource("getTrends", LoadData())); // Add the reportviewer to the form reportViewer1.Dock = DockStyle.Fill; // Process and render the report reportViewer1.RefreshReport(); } catch (Exception ex) { StreamWriter writer = new StreamWriter(logFile, true, System.Text.Encoding.ASCII); writer.WriteLine(System.DateTime.Now); writer.WriteLine("[generate report]"); writer.WriteLine("[generate report]"); writer.WriteLine(ex); writer.WriteLine("\r"); writer.Close(); MessageBox.Show(ex.ToString()); //this.Close(); //System.Environment.Exit(0); } this.Cursor = Cursors.Default; } private DataTable LoadData() { // Load data from XML file DataSet ds = new DataSet(); string myFilePath = (Application.StartupPath + "\\bin\\" + "trd.xml"); ds.ReadXml(myFilePath); return ds.Tables[0]; } tia rafone Statistics are like bikini's... What they reveal is astonishing ... But what they hide is vital ...

      R Offline
      R Offline
      Rafone
      wrote on last edited by
      #2

      It seems that the code works great. I deleted the report file and it worked. reafone

      Statistics are like bikini's... What they reveal is astonishing ... But what they hide is vital ...

      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