Solved

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

Posted on 2014-09-06
2
3,040 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
2 Comments
 
LVL 35

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Import Data from Multiple Text Files in Excel 12 60
ASP/VB email question 4 46
Help with opening combobox using VB.NET. 3 25
How to limit User Input 2 27
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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 …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 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