Other Languages - How to bind SP Values to a RDLC Report

Asked By Ramachandran on 28-Dec-11 04:27 AM
Plse provide me a simple example for binding the Stored procedure values to the RDLC Report with step by step procedure 
Web Star replied to Ramachandran on 28-Dec-11 04:29 AM
This is complete code how can call sp with rdlc report

protected void LoadReport(int lineNr)
{
    //  1. Clear Report Data
    ReportViewer1.LocalReport.DataSources.Clear();  

    //  2. Get Connection String from Web.Config
    SqlConnection sqlCon = new SqlConnection();
    sqlCon.ConnectionString = 
      ConfigurationManager.ConnectionStrings
      ["myConnection"].ConnectionString;

    //  3. Create DataSets (In my case I use 2 DataSets,
    //     you can use one or more)
    DataSet dsHeader = new DataSet();
    DataSet dsDetail = new DataSet();


    //  4. Select the DataSource to both DataSets
    // (In my case both SQL Stored Procedures
    //   use the same Sql parameter)

    SqlParameter sqlParm = new SqlParameter("@intNr", 
                                            lineNr.ToString());
    dsHeader = SqlHelper.ExecuteDataset(sqlCon, 
               CommandType.StoredProcedure, 
               "stp_S_LoadHeaderData",sqlParm);
    dsDetail = SqlHelper.ExecuteDataset(sqlCon, 
               CommandType.StoredProcedure, 
               "stp_S_LoadDetailData",sqlParm);

    //  5. The next lines mean that you will fill the datasets
    //     with the data retrieved from the stored procedures.
    //     I had on my SQL database, giving a input parameter
    //     sqlParam as you can see before
    //     Create datasource to the report - this way you associate
    //     these local datasets to your project datasets,
    //     with the correctly loaded data
    //     Notice that DS1_stp_s_LoadHeaderData and
    //     DS1_stp_s_LoadDetailData are my Report DataSets,
    //     so you can Map the local Datasets to the report datasets

    ReportDataSource reportDSHeader = 
      new ReportDataSource("DS1_stp_s_LoadHeaderData", 
                           dsHeader.Tables[0]);
    ReportDataSource reportDSDetail = 
      new ReportDataSource("DS1_stp_s_LoadDetailData", 
                           dsDetail.Tables[0]);

    //  6. Add these DataSources to your ReportViewer, et voilá!

    ReportViewer1.LocalReport.DataSources.Add(reportDSHeader);
    ReportViewer1.LocalReport.DataSources.Add(reportDSDetail);

    ReportViewer1.LocalReport.Refresh();
}

Reena Jain replied to Ramachandran on 28-Dec-11 04:33 AM
Hi,

An rdlc Report Document is also another XML based document that defines how the data should be displayed. I'm not going to demonstrate how to form a report here. But there are some things you should know, so I'll form a checklist of actions to build a report.

  1. Form a schema of the DataSet which you will use (dsHesapPlan.WriteXmlSchema()).
  2. Add the schema to your Visual Studio Project. The schema will be visible within the Data Sources window.
  3. By using this schema, design your report.
  4. After you complete designing the report, save the project.
  5. Inside your project folder, you'll find the *.rdlc report document. Take it for redistribution.
for more detail check this
http://www.codeproject.com/KB/cs/reportdisplay.aspx
Hope this will help you