none
create a drill through report(.rdlc) in vb.net winform with microsoft reportviewer control RRS feed

  • Question

  • hello, I have a parent and child report that I created in visual studio 2010 using winforms in vb.net. I have setup one text box in the parent report to go to the child report with the respective value as the parameter. However, when I click on the link I get the error: a data source instance has not been supplied for the data source 'dataset1'

    I realize that the dataset1 has to be filled, however I cannot figure out how to fill dataset1. I have researched the topic cand came with the following links:

    http://www.developerfusion.com/t/vb.net/

    http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportviewer.drillthrough.aspx

    On the winform where the reportviewer controller is located, I have the report drill through handler, but I do not understand how to set the dataset.

    I have the following, and I am stuck on how to move on:

      Private Sub ReportViewer1_Drillthrough(ByVal sender As System.Object, ByVal e As Microsoft.Reporting.WinForms.DrillthroughEventArgs) Handles ReportViewer1.Drillthrough
    
        Dim localreport = ReportViewer1.LocalReport
        Me.Sp_get_testaccountsTableAdapter1.Fill(Me.Retreival.sp_get_testaccounts)
    
        Dim od As New RetreivalTableAdapters.sp_get_testaccountsTableAdapter
    
        Dim myReportDataSource = New ReportDataSource( _
          "DataSet1", Me.sp_generate_accountreportBindingSource)
        localreport.DataSources.Add(myReportDataSource)
    
    
      End Sub
    
    
     so over here, I am filling the table adapter that dataset 1 is supposed to be connected to, but the dataset1 is still not filling... Please help!

    Do I need to set a new sqlconnection?? Why do I need to do this? Why can I not just use the sqlconnection string that my tableadapter is using??

    Thank you for your help!!


    ddd
    • Moved by Liliane Teng Monday, May 9, 2011 9:24 AM (From:Visual Basic General)
    Thursday, May 5, 2011 8:54 PM

All replies

  • You are filling sp_get_testaccounts. Why this isnt associated to the data source?
    Ali Hamdar (alihamdar.com - www.ids.com.lb)
    Thursday, May 5, 2011 9:19 PM
  •   Private Sub ReportViewer1_Drillthrough(ByVal sender As System.Object, ByVal e As Microsoft.Reporting.WinForms.DrillthroughEventArgs) Handles ReportViewer1.Drillthrough
    
        Dim localreport = ReportViewer1.LocalReport
        Me.Sp_get_testaccountsTableAdapter1.Fill(Me.Retreival.sp_get_testaccounts)
    
        Dim od As New RetreivalTableAdapters.sp_get_testaccountsTableAdapter
    
        Dim myReportDataSource = New ReportDataSource( _
          "DataSet1", Me.SpgettestaccountsBindingSource)
        localreport.DataSources.Add(myReportDataSource)
    
    
      End Sub
    
     
    

    my code has been changed above...

    the spgettestaccountsbindingsource was not used because the parent report was not using that stored procedure....

    So i have changed it, and I still receive the same error..


    ddd
    Thursday, May 5, 2011 9:26 PM
  • I also tried this:

    Private Sub ReportViewer1_Drillthrough(ByVal sender As System.Object, ByVal e As Microsoft.Reporting.WinForms.DrillthroughEventArgs) Handles ReportViewer1.Drillthrough
    
        Dim localreport = ReportViewer1.LocalReport
        Me.Sp_get_testaccountsTableAdapter1.Fill(Me.Retreival.sp_get_testaccounts)
    
        Dim od As New RetreivalTableAdapters.sp_get_testaccountsTableAdapter
    
        Dim myReportDataSource = New ReportDataSource( _
          "DataSet1", Me.Sp_get_testaccountsTableAdapter1.Fill(Me.Retreival.sp_get_testaccounts))
        localreport.DataSources.Add(myReportDataSource)
    
    
      End Sub
    
    

    but i get the error:

    {"The report data source object must be of the type System.Data.DataTable, System.Collections.IEnumerable, System.Windows.Forms.BindingSource, or System.Type."}

     


    ddd
    Thursday, May 5, 2011 9:29 PM
  • The fill method does not return a datatable. You need to do the Fill on a separate code line that give a datatable to the New ReportDataSource ...

     

     Me.Sp_get_testaccountsTableAdapter1.Fill(Me.Retreival.sp_get_testaccounts)

    Dim myReportDataSource = New ReportDataSource( _
       "DataSet1", Me.Retreival.sp_get_testaccounts)
      localreport.DataSources.Add(myReportDataSource)


    And the name of the data source here in your example you put "DataSet1" - the name should match the one in the RDLC report.


    Ali Hamdar (alihamdar.com - www.ids.com.lb)
    Thursday, May 5, 2011 9:50 PM
  • ali,

    thanks for your help btw.

    I now have the following code

    i get the error:

     Error 1 Overload resolution failed because no accessible 'New' is most specific for these arguments:
        'Public Sub New(name As String, dataSourceValue As System.Collections.IEnumerable)': Not most specific.
        'Public Sub New(name As String, dataSourceValue As System.Data.DataTable)': Not most specific. C:\Users\dbansal\Documents\Visual Studio 2010\Projects\CAG\CAG\FormReport.vb 23 34 CAG

      Private Sub ReportViewer1_Drillthrough(ByVal sender As System.Object, ByVal e As Microsoft.Reporting.WinForms.DrillthroughEventArgs) Handles ReportViewer1.Drillthrough
    
        Dim localreport = ReportViewer1.LocalReport
        Me.Sp_get_testaccountsTableAdapter1.Fill(Me.Retreival.sp_get_testaccounts)
    
        Dim od As New RetreivalTableAdapters.sp_get_testaccountsTableAdapter
    
        Dim myReportDataSource = New ReportDataSource("Retreival", Me.Retreival.sp_get_testaccounts)
        localreport.DataSources.Add(myReportDataSource)
    
    
      End Sub
    

    ddd
    Thursday, May 5, 2011 11:24 PM
  • Me.Retreival.sp_get_testaccounts is a dataset - the New should have a datatable.

    Retrieve the datatable from your dataset by using Me.Retreival.sp_get_testaccounts.Tables[0] and use it instead of the dataset.

    Ali Hamdar (alihamdar.com - www.ids.com.lb)
    Friday, May 6, 2011 7:37 AM
  • Sorry, this is VB replace the [ ] with ( )


    Retrieve the datatable from your dataset by using Me.Retreival.sp_get_testaccounts.Tables(0) and use it instead of the dataset.

    Ali Hamdar (alihamdar.com - www.ids.com.lb)
    Friday, May 6, 2011 7:53 AM
  • Ali,

    This is my code now:

    Private Sub ReportViewer1_Drillthrough(ByVal sender As System.Object, ByVal e As Microsoft.Reporting.WinForms.DrillthroughEventArgs) Handles ReportViewer1.Drillthrough
    
        Dim localreport = ReportViewer1.LocalReport
        Me.Sp_get_testaccountsTableAdapter1.Fill(Me.Retreival.sp_get_testaccounts)
    
        Dim od As New RetreivalTableAdapters.sp_get_testaccountsTableAdapter
    
        Dim myReportDataSource = New ReportDataSource("Retreival", Me.Retreival.sp_get_testaccounts.DataSet.Tables(0))
        localreport.DataSources.Add(myReportDataSource)
    
    
      End Sub
    

     

    however, now although it builds upon clicking the textbox that is supposed to drill through on my parent report. I get the error a data source instance has not been supplied for the data source 'dataset1'


    ddd
    Friday, May 6, 2011 11:46 AM
  • Ali,

    This is my code now:

    Private Sub ReportViewer1_Drillthrough(ByVal sender As System.Object, ByVal e As Microsoft.Reporting.WinForms.DrillthroughEventArgs) Handles ReportViewer1.Drillthrough
    
    
    
        Me.Sp_get_testaccountsTableAdapter1.Fill(Me.Retreival.sp_get_testaccounts)
        ReportViewer1.ProcessingMode = ProcessingMode.Local
        Dim localReport = ReportViewer1.LocalReport
        localReport.DataSources.Add(New ReportDataSource("Retreival", Me.Retreival.sp_get_testaccounts.DataSet.Tables(0)))
    
        Me.ReportViewer1.RefreshReport()
    
    
    
      End Sub
    
    

    However, now I get the error ' some credentials or parameters have not been supplied'  Currently, my stored procedure does not need a parameter. 

    When I click on the refresh button I get data source instance has not been supplied for the data source'dataset1'

    when i try to click back arrow I get object reference not set to an instance of an object.


    ddd
    Friday, May 6, 2011 12:19 PM
  • Hello dbansal,

    I have moved this thread to Visual Studio Report Controls forum where mainly discusses reporting functionality in Visual Studio. It is more appropriate for such issues. There you may get more better suggestions because more this aspect experts live there. Thanks for your understanding.

    If you have any concerns, please feel free to follow up.

    Have a nice day.

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Monday, May 9, 2011 9:29 AM