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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

kdwoodCommented:

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

Thanks,

Keith

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kdwoodCommented:
No need to give me the points...you found a much better solution.

Regards,

Keith
brokeMyLegBikingAuthor Commented:
It's easier to give you the points that post a cleanup question :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.