Solved

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

23 Experts available now in Live!

Get 1:1 Help Now