Visual Studio Development Bookmark and Share   
 index > Visual Studio Report Controls > Binding dataset at runtime without using tableadapter
 

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.)?

SMang  Monday, March 27, 2006 9:45 AM

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 theLocalReport DataSource.

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

William Vaughn  Monday, March 27, 2006 10:48 AM

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 modulein 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.

SMang  Monday, March 27, 2006 3:20 PM

William Vaughn wrote:

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

Great new! When will this be published? Good Work!

Fabio Pagano  Monday, March 27, 2006 6:01 PM

// 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();

  • Proposed As Answer byggponti Monday, October 20, 2008 6:56 PM
  •  
ggponti  Tuesday, March 28, 2006 6:51 PM

Thanks ggponti.

I can also refer to this article.

www.codeproject.com/useritems/reportdisplay.asp

www.rdleditor.com

 

SMang  Friday, March 31, 2006 7:00 AM

You can use google to search for other answers

Custom Search

More Threads

• textbox height?
• Fonts of the report
• ReportViewer issues with W2K
• Report Viewer internal state / multithreading
• reportviewer [=Fields!]NOME.Value
• Drillthrough Report Shows No Data
• programaticly change the orientation of reportviewer
• FieldAccessException error when viewing a report.
• Counting rows in datasource with specific filter
• date display formatting on y axis in rdlc chart reports