Binding dataset at runtime without using tableadapter

Hi all,

I am currently working on a reporting component of a project. We have already defined and coded our stored procedures and data generation modules.

So, I have a dataset which has data populated in runtime and I have my reportviewer control. What I need is a report object and binding that object to the dataset in runtime.

In order to form the report object, I need to add a datasource. After all the searches I have done, I figured out how to form the report for a dataset that does not have the data in it yet. I've created an XSD schema of the dataset and used it as the datasource to define which dataset column will be visible in which report column.

My question is, how can I bind my dataset, that will have data in it in runtime, without using ANY sql within the controls, or without using any object that has sql statements or call to stored procedures within (for ex. TableAdapter object.)




Answer this question

Binding dataset at runtime without using tableadapter

  • Grant Dickinson

    // render via the ReportViewer control
    reportViewer.ProcessingMode = ProcessingMode.Local;

    // set report
    reportViewer.LocalReport.ReportPath = "MyReport.rdlc";

    // set data
    DataTable dt = dataSet.Tables[ 0 ];
    reportViewer.LocalReport.DataSources.Add( new ReportDataSource( "MyDataSet", dt ) );

    // render report
    reportViewer.RefreshReport();


  • mmallett

    Thanks ggponti.

    I can also refer to this article.

    www.codeproject.com/useritems/reportdisplay.asp

    www.rdleditor.com

     



  • Mark Arteaga

    As I've said before, I used an XSD Schema of the actual dataset to form the report on design time and bind it as a business object data source to the reportviewer. I've managed to transfer the contents of the actual dataset into the made up dataset which has been created during binding of the report to the reportviewer in design time.

    That solved my current problem. But I need it all to be in run time. After a dataset and a report created for that dataset arrives to my module in runtime, my reportviewer should be able to show the report correctly for each report and dataset pair arrived.

    I will search for this and if I come out with something useful, I'll post it here.



  • Andural69

    Yes, it's entirely possible to create a report that's generated from your own DataTable. One way or another you're going to need to create either a (strongly type) TableAdapter or an untyped DataSet to let the UI generate the needed column references that can be bound to report items (like the Table item). When using either means you're going to have to manage any input parameters, instantiate the class(es), open the connection, execute the query(ies) and create a DataTable that's bound to the LocalReport DataSource.

    I'll be demonstrating this at the SQL/VS Connections conference in Orlando the week of April 3rd. Come on down and I'll show you some examples. Otherwise you'll have to wait for my book...



  • edgar-caballero

    William Vaughn wrote:

    "Otherwise you'll have to wait for my book..."

    Great new! When will this be published Good Work!


  • Binding dataset at runtime without using tableadapter