Asked by:
Using ReportViewer with SQLDataSource and MySQL

Question
-
User-1939834628 posted
Hallo,
I've been asked to upgrade some asp.net form associated with a report running on IIS with MySQL database.
Such .rdlc reports have been created with an older release of MS ReportDesigner. I found this reference inside .rdlc files:
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
I need to make some major modification to several forms running reports trough tags like this:
<rsweb:ReportViewer ID="rptData" runat="server" Height="440px" Width="100%" Visible="true">
<LocalReport ReportPath="report.rdlc" EnableHyperlinks="true">
</LocalReport>
</rsweb:ReportViewer>
The current source code create a dataset to feed report in codebehind with obsolete, unsafe and pretty error prone code. I would like to switch to databound components and possibily use SQLDataSource instead (using a more up-to-date paradigm like Entities will require too much work at this time).
Proceding on my job I'm facing a lot of strange errors most of which are given to my superficial knowledge of ReportViewer and/or MS reports in general.
The first issue follows any attempt to edit the report trough Visual Studio embeeded report designer... it need to replace xmlns entry described above with an updated one but this triggers the following error:
The report definition is not valid. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition' which cannot be upgraded.
Using VS report editor is not mandatory but it will speed up the upgrade process and anyway I don't understand why an outdated 2008 reportdefinition should be more acceptable than newer ones.
The second issue relates to the report .rdlc file loading: It seems that the only way to correctly locate the report file is to specificy its absolute path in ReportPath property... unluckly this's only possibile on local test machine but not on the server.
I fixed this trough codebehind using:
rptData.LocalReport.ReportPath = Server.MapPath("report.rdlc");
For some reason this correctly locates the report in the current folder (same of the form running the report) but prevent report from being previewed at design time in VisualStudio.
Is possibile to fix this trough .ASPX code?
The last question is related to SQLDataSource databinding. It seems that's possibile to bind report to such kind of data-source. I found a number of example of people doing so and using just something like this between LocalReport tags:
<DataSources> <rsweb:ReportDataSource DataSourceId="sdsData" /> </DataSources>
but what's the correct workflow to make this? (from the the implant of the report in the form to datasource field mapping)
I tried to make a report form from scratch trough Visual Studio project templates but it seems to rely on .xtd files that I would like to avoid if possible.
---- UPDATE ----
If I try to add a new ReportViewer tag to an empty form I got this (inside Visual Studio preview):
Error creating control - rptData to create designer 'Microsoft.Reporting.WebForms.ReportViewer, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I googled the error code and found that this should be related to the current version of nuget packages:
<package id="Microsoft.ReportViewer.Common" version="10.0.40219.1" targetFramework="net45" /> <package id="Microsoft.ReportViewer.WebForms" version="10.0.40219.1" targetFramework="net45" />
used by my site solution. But trying to find a working one like this:
<package id="Microsoft.ReportingServices.ReportViewerControl.WebForms" version="150.1400.0" targetFramework="net45" />
the only (negative) change is a compilation time error:
Error CS0234 type or namespace 'Reporting' does not exist in namespace 'Microsoft'....
What's the correct set of packages / references to be used to make report works?
---- UPDATE 2 ----
This mix of packages seems to allow report preview (at least with reports created from scratch) and run without errors. The only negative sideffect is the need of .xtd files instead SQLDataSources:
<package id="Microsoft.ReportingServices.ReportViewerControl.WebForms" version="150.1449.0" targetFramework="net45" /> <package id="Microsoft.ReportingServices.ReportViewerControl.Winforms" version="150.1449.0" targetFramework="net45" /> <package id="Microsoft.SqlServer.Types" version="14.0.1016.290" targetFramework="net45" />
Best regards,
Mike
Tuesday, March 30, 2021 12:23 PM
All replies
-
User-939850651 posted
Hi weirdgyn1972,
What's the correct set of packages / references to be used to make report works?I'm not sure how you did it. If you need to add dependencies, you could try this:
- Right click on References under the project
- select Add Reference...
- select Assemblies
- select Extensions
- find Microsoft.ReportViewer.WebForms
- Click ok to apply
Something like this:
Hope this can help.
Best regards,
Xudong Peng
Wednesday, March 31, 2021 5:48 AM -
User-1939834628 posted
I was sure this reference was already present in my project but I did fail..
I mean.. the reference is present but it's not listed between Extensions.
It's a normal behaviour? I mean .. the referenced assemblies are removed from available extensions list ?
Wednesday, March 31, 2021 8:59 AM -
User-939850651 posted
Hi weirdgyn1972,
I was sure this reference was already present in my project but I did fail..
I mean.. the reference is present but it's not listed between Extensions.
It's a normal behaviour? I mean .. the referenced assemblies are removed from available extensions list ?
I'm not sure how you did it to get this result. Did you download the "ReportViewer.WebForms.dll" assembly directly and put it directly in the project directory?
If this is the case, you could select it from broswe, the premise is that you need to accurately find the location where the assembly is stored in the machine.
Best regards,
Xudong Peng
Thursday, April 1, 2021 8:44 AM