Solved

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

Posted on 2014-09-06
2
3,168 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 500 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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Help with exporting to excel 4 46
FInd Image Control Gridview 3 38
Groupbox Control ? 2 30
VB/ASP.Net "Value of type 'Date' cannot be converted to 'Integer'" 12 43
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 was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

696 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