locked
First Effort with Report Control - 2nd Data Source not binding/rendering RRS feed

  • Question

  • Values from second report data source not binding / rendering....

    I have confirmed that my second data source is in the data source collection and it has a row in it per intellisence.

    Refresh() is called as last step... code block posted below and thanks..

     

    reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.

    ProcessingMode.Local;

     

    LocalReport localReport = reportViewer1.LocalReport;

     

    //localReport.ReportPath = "PrintQuoteLocalReport.rdlc";

    reportViewer1.LocalReport.ReportEmbeddedResource =

    "TestWindowsFormsApplication.PrintQuoteLocalReport.rdlc";

     

    DataSet dataset = new DataSet("PrintQuoteData");

     

    SqlConnection conn = new SqlConnection("Data Source=tex;Initial Catalog=Trio;Integrated Security=SSPI;");

     

    SqlCommand cmd = new SqlCommand("dbo.reports_sp_PrintQuote", conn);

    cmd.CommandType =

    CommandType.StoredProcedure;

     

    SqlParameter docNumber = new SqlParameter("@arOrderDocumentNumber",SqlDbType.Int);

    docNumber.Direction =

    ParameterDirection.Input;

    docNumber.Value = textBox1.Text;

    cmd.Parameters.Add(docNumber);

     

    SqlDataAdapter adapter = new SqlDataAdapter(cmd);

    adapter.Fill(dataset,

    "PrintQuoteData");

    reportViewer1.LocalReport.DataSources.Add(

     

    new Microsoft.Reporting.WinForms.ReportDataSource(

     

    "PrintQuoteData_reports_sp_PrintQuote", dataset.Tables[0]));

    reportViewer1.RefreshReport();

     

    // get the data for the detail

     

     

    SqlConnection conn2 = new SqlConnection("Data Source=tex;Initial Catalog=Trio;Integrated Security=SSPI;");

     

    SqlCommand cmd2 = new SqlCommand("dbo.reports_sp_PrintQuoteDetail", conn);

    cmd2.CommandType =

    CommandType.StoredProcedure;

     

    SqlParameter docNumber2 = new SqlParameter("@arOrderDocumentNumber", SqlDbType.Int);

    docNumber2.Direction =

    ParameterDirection.Input;

    docNumber2.Value = textBox1.Text;

    cmd2.Parameters.Add(docNumber2);

     

    SqlDataAdapter adapter2 = new SqlDataAdapter(cmd2);

     

    DataSet dataset2 = new DataSet("PrintQuoteDetailData");

    adapter.Fill(dataset2,

    "PrintQuoteDetailData");

     

    //DataTable dt = dataset.Tables[0];

    reportViewer1.LocalReport.DataSources.Add(

     

    new Microsoft.Reporting.WinForms.ReportDataSource(

     

    "PrintQuoteDetailData_reports_sp_PrintQuoteDetail", dataset2.Tables[0]));

     

     

     

    reportViewer1.RefreshReport();

     

     


    Doyle
    Thursday, July 1, 2010 2:40 PM

All replies

  • Please wrap you code in code blocks so it is easier to read in your post.

    Is your second datasource for a sub report? If so, then you can't add it directly. You have to start rendering the report and catch the event SubreportProcess and process it.

    For example;

    mrvMicrosoftViewer.LocalReport.SubreportProcessing +=
                new SubreportProcessingEventHandler(SubreportProcessingEventHandler);

    catches the event and;

    public void SubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
    {
      e.DataSources.Add(new ReportDataSource("dsMyData_Details", dsData.Tables["Details"]));
    }                               
    

    handles it by adding the datasource it needs.

    Here is a good example of the whole process;

    http://www.gotreportviewer.com/Subreport.zip

    Does this help any?

    Bernie

     

    Saturday, July 3, 2010 4:42 PM