?
Solved

How to use DataTable as ReportViewer data source in VB.net, VS2010?

Posted on 2014-09-06
2
Medium Priority
?
3,643 Views
Last Modified: 2014-09-07
Hello,

Using VB.net on VS2010.  Reworking old project.  

Here's the situation:

* I have a DataTable (myDataTable) with data in it.  It's created programmatically.

* I've created a ReportViewer (myReportViewer) on my WinForm (myForm).

* How do I use myDataTable as myReportViewer's data source?

Specific code example would be much appreciated.

Thanks!
0
Comment
Question by:SqueezeOJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 2000 total points
ID: 40308104
Load the datable to your local report property as follows:
myReportViewer.LocalReport.DataSources.Clear()
Dim rprtDTSource As Microsoft.Reporting.WinForms.ReportDataSource  = new Microsoft.Reporting.WinForms.ReportDataSource(myDataTable.TableName, myDataTable)
myReportViewer.LocalReport.DataSources.Add(rprtDTSource) 
myReportViewer.RefreshReport()

Open in new window

0
 

Author Closing Comment

by:SqueezeOJ
ID: 40308569
Great code - Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question