Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having trouble with MS Report Viewer

Status
Not open for further replies.

CraigBest

Programmer
Aug 1, 2001
545
US
Hi folks

Got a bit of a head-banger going here. I'm trying to use the Microsoft Report Viewer control and an RDLC report to show some data from my project. But I'm having some trouble trying to get it to work the way I want it to (and how I think it should). Here's what I've got:

I created an RDLC report file from a data source object linked to a query in my Access database (there seemed to be no other way to do this, I could not find a way to create data object fields on the report without doing so). However, I would prefer to create a data table myself and pass it to the Report Viewer along with the RDLC report file and have it display the data I choose to send (in the same structure and format, of course). This is not working as I think it should; in fact I get nothing in the report viewer when I run the program except a single line stating there is nothing defined for the data source (it names the data object used to build the report). My data table is the result from the same query used to create the report file so that should not be an issue.

I'm using some sample code I found to instantiate the report that's supposed to allow you to pass a dataset along with the report filename/path. However, I'm passing a data table only (that could be part of the problem). My code is shown below, dt is the data table object being passed:
Code:
        RptViewer.LocalReport.DataSources.Clear()
        RptViewer.LocalReport.ReportPath = gsRptPath & "\rptCommBal.rdlc"
        Dim dsReport = New Microsoft.Reporting.WinForms.ReportDataSource("DS", dt)
        RptViewer.LocalReport.DataSources.Add(dsReport)
        RptViewer.ProcessingMode = ProcessingMode.Local
        RptViewer.RefreshReport()
Any suggestions on what I might do to make this work? I figure I'm missing something, or will the MS Repot viewer only work with an associated data source to draw from?


CraigHartz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top