brokeMyLegBiking
asked on
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,
https://www.experts-exchange.com/questions/21793631/Visual-Studio-2005-ReportViewer-Control-URGENT-HELP-NEEDED.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=(loc al)\MYINST ANCE;Datab ase=SFS_IS LAND_WORKI NG;Integra ted 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.LocalRepo rt.ReportE mbeddedRes ource = "reportViewer.Report3.rdlc "
Dim dsource As New mr.ReportDataSource("Adven tureWorksD ataSet_Dat aTable1", dt)
ReportViewer1.LocalReport. DataSource s.Add(dsou rce)
Me.ReportViewer1.RefreshRe port()
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,
https://www.experts-exchange.com/questions/21793631/Visual-Studio-2005-ReportViewer-Control-URGENT-HELP-NEEDED.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=(loc
cn.Open()
Dim cmd As New SqlCommand("select * from vw_report_membershiproster
Dim da As New SqlDataAdapter(cmd)
da.Fill(dt)
'---
Me.ReportViewer1.LocalRepo
Dim dsource As New mr.ReportDataSource("Adven
ReportViewer1.LocalReport.
Me.ReportViewer1.RefreshRe
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No need to give me the points...you found a much better solution.
Regards,
Keith
Regards,
Keith
ASKER
It's easier to give you the points that post a cleanup question :)
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=(loc
cn.Open()
myTable = "T"
mySQL = "select * from vw_report_membershiproster
da = New SqlDataAdapter(mySQL, cn)
da.Fill(myDS, myTable)
Me.ReportViewer1.LocalRepo
Dim dsource As New mr.ReportDataSource("Adven
ReportViewer1.LocalReport.
Me.ReportViewer1.RefreshRe
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