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. Windows Forms
  4. rdlc report in c# winforms programmatically

rdlc report in c# winforms programmatically

Scheduled Pinned Locked Moved Windows Forms
csharpwinformshelp
3 Posts 3 Posters 6 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.
  • I Offline
    I Offline
    Irshadkk
    wrote on last edited by
    #1

    I got the report using rdlc by the report wizard but i can't view anything by using this methode programmatically.. Here I just added a report file report2.rdlc and a report viewer reportViewer2 to the form. and no more process done with out the following code in a button click My code in button click event ''''''''''''''''''''''''''''' String get_results = "SELECT * FROM Employee"; SqlConnection con = new SqlConnection(@"Connection String"); con.Open(); SqlDataAdapter adp = new SqlDataAdapter(get_results, con); DataSet ds = new DataSet(); adp.Fill(ds); Microsoft.Reporting.WinForms.ReportDataSource repds = new Microsoft.Reporting.WinForms.ReportDataSource("Employee",ds.Tables[0]); reportViewer2.ProcessingMode = ProcessingMode.Local; String rPath = @"F:\report\report2.rdlc"; reportViewer2.LocalReport.ReportPath = rPath; reportViewer2.LocalReport.DataSources.Clear(); reportViewer2.LocalReport.DataSources.Add(repds); reportViewer2.Visible = true; reportViewer2.RefreshReport(); ... i don't get any result on my form... if it need to assign something to the rdlc file or reportviwer other than the above code, or should i insert a dataset or anything other than the code.. if it need please help me it in programmatically....

    B X 2 Replies Last reply
    0
    • I Irshadkk

      I got the report using rdlc by the report wizard but i can't view anything by using this methode programmatically.. Here I just added a report file report2.rdlc and a report viewer reportViewer2 to the form. and no more process done with out the following code in a button click My code in button click event ''''''''''''''''''''''''''''' String get_results = "SELECT * FROM Employee"; SqlConnection con = new SqlConnection(@"Connection String"); con.Open(); SqlDataAdapter adp = new SqlDataAdapter(get_results, con); DataSet ds = new DataSet(); adp.Fill(ds); Microsoft.Reporting.WinForms.ReportDataSource repds = new Microsoft.Reporting.WinForms.ReportDataSource("Employee",ds.Tables[0]); reportViewer2.ProcessingMode = ProcessingMode.Local; String rPath = @"F:\report\report2.rdlc"; reportViewer2.LocalReport.ReportPath = rPath; reportViewer2.LocalReport.DataSources.Clear(); reportViewer2.LocalReport.DataSources.Add(repds); reportViewer2.Visible = true; reportViewer2.RefreshReport(); ... i don't get any result on my form... if it need to assign something to the rdlc file or reportviwer other than the above code, or should i insert a dataset or anything other than the code.. if it need please help me it in programmatically....

      B Offline
      B Offline
      BELGIUMsky
      wrote on last edited by
      #2

      Can you try reportViewer2.LocalReport.ReportEmbeddedResource = "report.report2.rdlc" Instead of reportViewer2.LocalReport.ReportPath = rPath;

      1 Reply Last reply
      0
      • I Irshadkk

        I got the report using rdlc by the report wizard but i can't view anything by using this methode programmatically.. Here I just added a report file report2.rdlc and a report viewer reportViewer2 to the form. and no more process done with out the following code in a button click My code in button click event ''''''''''''''''''''''''''''' String get_results = "SELECT * FROM Employee"; SqlConnection con = new SqlConnection(@"Connection String"); con.Open(); SqlDataAdapter adp = new SqlDataAdapter(get_results, con); DataSet ds = new DataSet(); adp.Fill(ds); Microsoft.Reporting.WinForms.ReportDataSource repds = new Microsoft.Reporting.WinForms.ReportDataSource("Employee",ds.Tables[0]); reportViewer2.ProcessingMode = ProcessingMode.Local; String rPath = @"F:\report\report2.rdlc"; reportViewer2.LocalReport.ReportPath = rPath; reportViewer2.LocalReport.DataSources.Clear(); reportViewer2.LocalReport.DataSources.Add(repds); reportViewer2.Visible = true; reportViewer2.RefreshReport(); ... i don't get any result on my form... if it need to assign something to the rdlc file or reportviwer other than the above code, or should i insert a dataset or anything other than the code.. if it need please help me it in programmatically....

        X Offline
        X Offline
        xstoneheartx
        wrote on last edited by
        #3

        Probably the name of dataset in your Report is different than "Employee". Open your report and in "Report Data" window, under the node "Datasets", check the name of your dataset, for example if dataset name is "Dataset1", your code should be:

        Microsoft.Reporting.WinForms.ReportDataSource repds = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", ds.Tables[0]);

        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