none
How to bind the dataset to the reportviewer dynamically... RRS feed

  • Question

  • Hi,

    I am using dot net 3.5 Framework. It is a Windows Application with vb.net.

    I have added an Dataset into my project and created  a datatable having two columns(ID, Name) Both are string columns . No Data is added into this Dataset.  This column name is dragged into the table of the report (RDLC ) file. With this the designing part of the rdlc report  is completed.Then a microsoft report viewer is added into the Form and  this RDLC report is selected in reportviewer tasks--> choose Reports --> Now the reportviewer setting is also completed..

    I will get another  dataset with same columns(ID,Name) in runtime say (button click..)This Dataset contains the real data... I need to use this as the datasource to this report..

    IF i use the following code data is not populating..

    ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Dataset1_DataTable1", NewDataSet.Tables(0)))

    Me.ReportViewer1.RefreshReport()



    Here "Dataset1_DataTable1", is the name of the report Datasource .
    "NewDataset" is the dataset having Data and structure is the same as the Dataset used for designing..

    How do i achieve this...

    What could be the Error in this..

    Thanks
    Radha krishnan


    Friday, September 18, 2009 4:26 AM

Answers

  • Radha, try...


    frm.ReportViewer1.LocalReport.DataSources.Add(

    New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_DataTable1", m_dt))

    ...where m_dt is your DataTable. You can also use a BindingSource, where you would state:

    bs.DataSource = m_dt

    frm.ReportViewer1.LocalReport.DataSources.Add(

    New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_DataTable1", bs))

     


    Fulano

    Friday, September 18, 2009 4:46 AM

All replies

  • Radha, try...


    frm.ReportViewer1.LocalReport.DataSources.Add(

    New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_DataTable1", m_dt))

    ...where m_dt is your DataTable. You can also use a BindingSource, where you would state:

    bs.DataSource = m_dt

    frm.ReportViewer1.LocalReport.DataSources.Add(

    New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1_DataTable1", bs))

     


    Fulano

    Friday, September 18, 2009 4:46 AM
  • Hi Fulano,

    Thanks for your reply....

    I have given the datasource Name as   "Dataset1_DataTable1" Instead of  "DataSet1_DataTable1".

    The mistake i did is that i was not concentrated on the Case of the Letters in the datasource Name..It is Case Sensitive.

    Now it works....

    Wednesday, September 23, 2009 10:20 AM