load datatable as source for reportviewer

G

Guest

Hello,
I have created a class that accepts a text file as input. The file is parsed
and a data table is returned. I then take the data table, load it into SQL,
and create a local reportviewer instance from a query on the SQL table. I
would like to do away with the requirement to load the data into SQL and
retrieve it from SQL and just pass the returned data table directly to the
reportviewer. I am using VS2005 Team Edition C# in a WinForm.


this is what I had in mind:
reportViewer2.ProcessingMode = ProcessingMode.Local;
reportViewer2.LocalReport.ReportPath = "Report1.rdlc";
reportViewer2.LocalReport.DataSources.Add(new ReportDataSource("DOH",
GetData2(inputFile))); //GetData2(inputFile) returns the datatable
reportViewer2.RefreshReport();

I am missing something, probably the dataadapter.
 
K

Kevin Yu [MSFT]

Hi James,

Do you need to add the DataTable directly as the ReportDataSource? If so,
as you know, we can use a DataAdapter to fill a new DataTable to create it.
You can use the following:

DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("SELECT ......",
this.SqlConnection);
sda.Fill(dt);

Return dt will return the DataTable. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
G

Guest

I am returning a data table from a dll. I can see the returned data table,
dt, and what I would like to do is display the contents of dt on the
reportviewer. I am having a problem determining how to make the reportviewer
display it. I need to associate the data table with the reportviewer
programmatically somehow.
 
K

Kevin Yu [MSFT]

Hi James,

Did you get anything shown on the report? Is there any message on the
reportviewer if you cannot see anything? If not, please set the DataTable
as datasource of a datagrid control to see if data has been successfully
filled into the DataTable.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top