none
How to make report in report viewer through stored procedure in windows forms RRS feed

  • Question

  • HI,

    i want to make a report through report viewer control and i have made stored procedure with the name 'usp_FetchAllEmp" but i am not getting understand that how to bind with report data source and finally how to show all the data in report viewer control.

    can anyone provide me code snippet for that so that i could tried that and resolve my issue.

    plz help me...


    Thursday, April 14, 2011 10:10 AM

Answers

  • Thanks for reply but can u please provide me some code snippet. so that i could start something to do...
    • Marked as answer by Jiten.negi Tuesday, April 19, 2011 4:55 AM
    Friday, April 15, 2011 4:50 AM
  • Hi all,

    i have got the solution of my problem.. Here is my code

     String s = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
          SqlConnection con = new SqlConnection();
          con.ConnectionString = s;
          //SqlConnection con = new SqlConnection(@"Data Source=AT1-PC\SQLEXPRESS;Initial Catalog=PCJDB;User ID=newuser;Password=newuser");
          SqlCommand cmdSelect = new SqlCommand("select P, G1, Item_Code from ItemSC", con);
          SqlDataReader dr;
          DataTable dt = new DataTable();
          DataSet ds = new DataSet();
          con.Open();
          dr = cmdSelect.ExecuteReader();
          dt.Load(dr);
          con.Close();
          Microsoft.Reporting.WinForms.ReportDataSource rds = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_ItemSC", dt);
          this.reportViewer1.LocalReport.DataSources.Add(rds);
          this.reportViewer1.LocalReport.ReportPath = @"E:\R and D\report\report\report\Report3.rdlc";
          this.reportViewer1.RefreshReport();
    

    for Showing data into the report viewer control...

     

    Thanks for reply into my questions...

    Practise Makes a Man Perfect... Never Give Up and Keep Trying until you get your desired output....

    • Marked as answer by Jiten.negi Tuesday, April 19, 2011 4:58 AM
    Tuesday, April 19, 2011 4:58 AM

All replies

  • You'll need to create a DataSet object in your project that fetches data using your stored procedure. You'll get a wizard for that when you drag a TableAdapter onto the DataSet Designer surface.

    Once you have that, you can design a report using report designer using the DataSet definition you created, then add it to the reportviewer control.


    Cephas Lin This posting is provided "AS IS" with no warranties.
    Thursday, April 14, 2011 7:43 PM
    Moderator
  • Thanks for reply but can u please provide me some code snippet. so that i could start something to do...
    • Marked as answer by Jiten.negi Tuesday, April 19, 2011 4:55 AM
    Friday, April 15, 2011 4:50 AM
  • Hi all,

    i have got the solution of my problem.. Here is my code

     String s = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
          SqlConnection con = new SqlConnection();
          con.ConnectionString = s;
          //SqlConnection con = new SqlConnection(@"Data Source=AT1-PC\SQLEXPRESS;Initial Catalog=PCJDB;User ID=newuser;Password=newuser");
          SqlCommand cmdSelect = new SqlCommand("select P, G1, Item_Code from ItemSC", con);
          SqlDataReader dr;
          DataTable dt = new DataTable();
          DataSet ds = new DataSet();
          con.Open();
          dr = cmdSelect.ExecuteReader();
          dt.Load(dr);
          con.Close();
          Microsoft.Reporting.WinForms.ReportDataSource rds = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_ItemSC", dt);
          this.reportViewer1.LocalReport.DataSources.Add(rds);
          this.reportViewer1.LocalReport.ReportPath = @"E:\R and D\report\report\report\Report3.rdlc";
          this.reportViewer1.RefreshReport();
    

    for Showing data into the report viewer control...

     

    Thanks for reply into my questions...

    Practise Makes a Man Perfect... Never Give Up and Keep Trying until you get your desired output....

    • Marked as answer by Jiten.negi Tuesday, April 19, 2011 4:58 AM
    Tuesday, April 19, 2011 4:58 AM