?
Solved

ReportViewer 2005 Local Report Datasource

Posted on 2006-04-11
5
Medium Priority
?
3,440 Views
Last Modified: 2010-04-19
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()
0
Comment
Question by:brokeMyLegBiking
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:kdwood
ID: 16431607
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
 
LVL 4

Author Comment

by:brokeMyLegBiking
ID: 16435243
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
 
LVL 10

Accepted Solution

by:
kdwood earned 2000 total points
ID: 16435306

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

Thanks,

Keith
0
 
LVL 10

Expert Comment

by:kdwood
ID: 16438387
No need to give me the points...you found a much better solution.

Regards,

Keith
0
 
LVL 4

Author Comment

by:brokeMyLegBiking
ID: 16441973
It's easier to give you the points that post a cleanup question :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

840 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