26

I have created a ReportProject with Visual Studio data tools 2015. When I create a report.rdl file using the report wizard, the rdl file has schema for 2016. My reporting server is of version 12.0.4213.0.

How can I create a report.rdl which is compatible with my reporting server. I tried changing the TargetServerVersion by right clicking the project -> properties and changing the targetserverversion to "Sql server 2008 R2, 2012 or 2014". But this doesn't work either.

Anirudhan J
  • 2,072
  • 6
  • 27
  • 45

7 Answers7

92

Edit: The specific version of the report you set as the TargetServerVersion property gets created in the BIN (\debug or wherever you build to) folder as long as you are not using any 2016 features.

I'm trying to find the same answer. You would think simply setting the solution's TargetServerVersion the way you did would cause it to use the right report definition (or optionally they could give you the option to add a pre-2016 report item)

Until then, if you right click the .rdl and "view code", you can change the following lines to make it work in SQL 2014 - just make a backup of your original .rdl in case you make a mistake:

1) Replace the report xmlns line with the following:

<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">

2) Remove the ReportSections and ReportSection lines, keeping the child tree structure body tag etc. below it). So remove these:

  <ReportSections>
    <ReportSection>

and these...

    </ReportSection>
  </ReportSections>

3) Remove the entire ReportParametersLayout section. So (e.g.) remove this:

  <ReportParametersLayout>
    <GridLayoutDefinition>
      <NumberOfColumns>4</NumberOfColumns>
      <NumberOfRows>2</NumberOfRows>
    </GridLayoutDefinition>
  </ReportParametersLayout>

Hit save, go back into the design and run the report. If you haven't modified the design it will work in SQL2014. The minute you change any fields it will revert to the 2016 schema.

If anyone sees a way to fix this behavior let us know. Thanks!

Trubs
  • 2,829
  • 1
  • 24
  • 33
tb1
  • 1,340
  • 12
  • 14
  • 2
    Thank you! You are a wizard. This has been tripping us up for some time now. – BossWalrus Mar 24 '17 at 21:39
  • 2
    When you build a report, it puts the correct version of xml you have _targeted_ (in the TargetServerVersion Property) into the \bin folder. Its **_that_** file that you need to upload to your server (NOT the file you are editing) and the namespaces and functionality will be fine. (note - the file in the \bin directory is the rdl that gets deployed when you use [Right-click deploy]) – Trubs Sep 26 '18 at 01:52
  • Hero solution. Thanks. – Hemant Ramphul May 25 '20 at 13:28
  • Muchas gracias. esto me salvo el dia. Me sirvio para version 2008R2 – lanshare May 31 '22 at 11:38
8

You can get reports in several different version formats from Visual Studio with the following steps:

  1. In project Property Pages set the TargetServerVersion to the desired format (in this case SQL Server 2008 R2, 2012 or 2014)
  2. Build the project
  3. Find the rdl's in the desired format in the build output folder (specified in project Property Pages also: Build => OutputPath)
Philip Bijker
  • 4,955
  • 2
  • 36
  • 44
  • 1
    this is the correct answer, I was always picking up the rdl in the project root folder but it is the one on the output that gets the correct namespace/version for my server! cheers! – Alex Mar 03 '20 at 23:45
7

I wrote a simple PowerShell script that follows the ideas of the accepted answer.

$file = (Get-Content "InputFileNameHere.rdl") 

# Unwraps the Body and the Page element. 
# Simple string replacement
$file = $file -replace '<ReportSections>',""
$file = $file -replace '<ReportSection>',""
$file = $file -replace '</ReportSection>',""
$file = $file -replace '</ReportSections>',""

# Parse the XML doc
$xml = [xml]$file;

# Set the XML namespace
$xml.Report.xmlns = "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition";

# Delete ReportParametersLayout node    
$xml.Report.RemoveChild($xml.Report.ReportParametersLayout);

# Save the file
Set-Content -Value $xml.OuterXml -Path "OutputFilenameHere.rdl"

Edit the first line to match your input file and the last line, save it as something.ps, run it and upload the new file.

lsu
  • 71
  • 1
  • 4
  • Thanks, this is useful. It also works for RDLC files such as what I am using. I recommend putting the path to the file in a variable and run it from a script like a PS1 file: `$path = "$PSScriptRoot\Invoice.rdlc"` `$file = (Get-Content $path)` – robbpriestley Jul 13 '18 at 21:52
4

In my case when I added parameters in RDLC Design , System throws exception at run time that the report definition has an invalid target namspace. I have just unintalled the Microsot report viewer v 12.0 and installed the Microsoft.ReportingServices.ReportViewerControl.Winforms from nugetpackages version 15 at that time the latest one Atfer installing my issue is resolved It took whole night to figure out. Issue was happening because I have VS 17 and I was using older Version of report viewer.

Awais Asghar
  • 149
  • 1
  • 5
2

Try this step I found on this link and worked for me: Error while uploading a report

  1. Using SSDT in 2016, Set your target sql version to SQL Server 2008 R2, 2012 or 2014
  2. Clean the solution
  3. Rebuild the solution
  4. Copy the content of your Bin\debug folder and replace the content of the main folder with it (Be sure to have a backup)
  5. SSRS 2010 should render your project
Community
  • 1
  • 1
1

Replace the second row of report code that has 2016 in it, with below:

<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">

Then locate the ReportParametersLayout section and remove it. Hit minus to show one line and right click and cut.

The above fixed four reports converted from Crystal to version 16, when I should have selected version 10.

avrahamcool
  • 13,888
  • 5
  • 47
  • 58
0

I faced the same problem... and the solution was to remove the report viewer 10.0.0.0 version and replace it with the appropriate 15.0.0.0

enter image description here

i removed the old reference for report viewer enter image description here

and installed the new one from the NuGut enter image description here

and the version is changed in the refrences to be 15.0.0.0 enter image description here

then it worked fine.