ReportViewer on the fly?

Posted on 2006-05-24
Medium Priority
Last Modified: 2010-04-16
Simply, I have a DataSet/DataTable which is filled from a specific and dynamic SQL Select statement, how could I view that Table in a ReportViewer control (not CrystalReportViewer control). Below my code:

string MyConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="Customers.mdb";

DataSet ds = new DataSet();

OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Customers", MyConnectionString);
// The SQL Select statement above could be anything else (I am getting it from user's input)

da.Fill(ds, "dt");

// What code should I put here so that the DataTable 'dt' could be viewed in the ReportViewer control


I am new on ths issue, and I am wondering if I could do this on the fly (dynamically/programatically) because I am not using any DataSource on my application. My application is just to print a given (dynamic) DataTable.
I am using C# .NET 2.0

Question by:salan_alani

Accepted Solution

e1v earned 1050 total points
ID: 16749781
It is possible to do this, but its not very easy...

There is an example (source code) on doing this at www.gotreportviewer.com, titled Generate RDLC dynamically - Table

Author Comment

ID: 16751238
Thanks e1v,

Do you have any article link on this issue, cause what I have here is only the source code without even any descriptions/comments on it.
Is this the only way or could be something else more easier cause I think the application should be easy just take a given DataTable then print it. I did before some class to print the DataGridView control with its style and it works fine except I was having some problems in wrapping issue, then I decided to take the advantage of the ReportViewer control cause I think it's the ideal way to do such stuff.

So if anyone could help with some articles and source code about this issue.
LVL 12

Assisted Solution

topdog770 earned 450 total points
ID: 16751618

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…

588 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