Solved

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

Posted on 2014-09-06
2
2,822 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

896 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now