ReportViewer 2005 Local Report Datasource

I am trying to dynamically assign local reports in the reportviewer control.  

I can’t seem to get a valid datasource for my rdlc.  All of the examples Can someone show me what I have to do in order to load an RDLC in the reportview with a valid datasource.  Thanks for the help

I've checked out this post,
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21793631.html
but I'm hoping for a solution in which I don't have to build a dummy dataset. I do this type of operation in Crystal reports all the time, so I'm hoping it's possible in ReportViewer control.

-Joseph


This is my code so far, but it keeps giving me an error saying that "table1 refers to an invalid DataSetName...
            Dim dt As New DataTable
            Dim cn As New SqlConnection("Server=(local)\MYINSTANCE;Database=SFS_ISLAND_WORKING;Integrated Security=True")
            cn.Open()
            Dim cmd As New SqlCommand("select * from vw_report_membershiproster", cn)
            Dim da As New SqlDataAdapter(cmd)
            da.Fill(dt)

            '---
            Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "reportViewer.Report3.rdlc"
            Dim dsource As New mr.ReportDataSource("AdventureWorksDataSet_DataTable1", dt)
            ReportViewer1.LocalReport.DataSources.Add(dsource)
            Me.ReportViewer1.RefreshReport()
LVL 4
brokeMyLegBikingAsked:
Who is Participating?
 
kdwoodCommented:

Good job Joseph...I will give this a try today.

Thanks,

Keith
0
 
kdwoodCommented:
Joesph,

The first issue I see is that you need to ultimately bind the ReportViewerControl to a DataSet.  So if you don't create a dummy one, we need to create one on the way in.

Try something like this in your opening code:

Dim myDS as New Dataset
Dim da As SqlDataAdapter
Dim myTable as string
Dim mySQL as String
Dim cn As New SqlConnection("Server=(local)\MYINSTANCE;Database=SFS_ISLAND_WORKING;Integrated Security=True")

cn.Open()

myTable = "T"

mySQL = "select * from vw_report_membershiproster"

da = New SqlDataAdapter(mySQL, cn)
da.Fill(myDS, myTable)

Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "reportViewer.Report3.rdlc"
Dim dsource As New mr.ReportDataSource("AdventureWorksDataSet_DataTable1", T)
ReportViewer1.LocalReport.DataSources.Add(dsource)
Me.ReportViewer1.RefreshReport()

Now, when I was struggling with this prior to my Post on the subject, I was able to get the dataset to fill and return data into the table.  However, I could not figure out how to get the fields on the report to map to the dataset with this approach.   Hopefully, you can figure it out.

Regards,

Keith
0
 
brokeMyLegBikingAuthor Commented:
ok, I found an easy solution, which makes life much better. It is a simple solution too, which is my favorite kind.

you just have to use a ".rdl" file instead of a ".rdlc".

An RDL file is created by SqlServer 2005's Business Intelligence Studio (which is actually just a special type of project in Visual Studio 2005).

Two benefits of RDL over RDLC that I have observed are: 1) I don't have to have a strongly typed dataset which creates lots of files in my project (xml, xsd...) for each report, which I didn't like, and each time you change the report you had to refresh the strongly typed dataset.

2) Most importantly, it works, and I don' t have to create a dummy dataset.

One more tip I figure out is that by combining my business intelligence project where I build the reports into the same solution as my VB.NET winforms project, I can just drag and drop reports from the first project into the second.

Very nice! So long crystal reports! (and good riddance)

-Joseph

0
 
kdwoodCommented:
No need to give me the points...you found a much better solution.

Regards,

Keith
0
 
brokeMyLegBikingAuthor Commented:
It's easier to give you the points that post a cleanup question :)
0
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.

All Courses

From novice to tech pro — start learning today.