- Using the BI Development studio.
- Using the SQL Server Management Studio
- Programmatically ( using RS.EXE utility)
The only option to deploy the report in this scenario is deploying reports programmatically.
RS.EXE is a Command-line utility which is used to perform deployment and other administrative task programmatically. This RS.EXE utility expects a file with the extension .RSS which is usually written in VB.NET. The RS file will contain script to create Report folder on the server, to create Report Data Source and to publish the reports as well.
Steps:
- Copy all the RDL file and RS file to server where you want to deploy the reports. Please note that all the RDL files and RS file (script file) needs to placed in the same folder.
- Open the command prompt and type the following command to execute the script:
- For example if you have all the files on a location “D:\Reports”
- D:\ Reports> rs -i FileName.rss -s http://localhost/ReportServer
This command will read the script from the” FileName.rss” file and create a report folder for you, report data source and publish all the reports you have mentioned in the file.
Below is the code for your RSS file.
Dim ReportSource As String
Public Sub Main()
TRY
ReportSource = "D:\Reports" ‘Path of the folder where script and reports file are located
rs.Credentials = System.Net.CredentialCache.
If rs.GetItemType("/Reports") = Microsoft.SqlServer.
rs.DeleteItem("/Reports") ‘Deleting the report folder if already exists
End If
rs.CreateFolder("Reports", "/", Nothing) ‘Creating the Report folder
Console.WriteLine("Parent folder [Reports] created successfully.")
CreateReportDataSource("
PublishReport("MyReport") ‘publishing reports with the name MyReport.rdl’
‘Note: you can publish as many reports you want, just keep adding ‘PublishReport(ReportName) method here,
Console.WriteLine("Tasks completed successfully.")
CATCH ex As Exception
THROW ex
END TRY
End Sub
Public Sub CreateReportDataSource(name As String, extension As String, connectionString As String)
'Data source definition.
Dim definition As New DataSourceDefinition()
definition.CredentialRetrieval = CredentialRetrievalEnum.
definition.ConnectString = connectionString
definition.Enabled = True
definition.Extension = extension
TRY
rs.
Console.WriteLine("Data source: {0} created successfully.", name)
CATCH e As Exception
Console.WriteLine(
THROW e
END TRY
End Sub
Public Sub PublishReport(ByVal reportName As String)
TRY
Dim stream As FileStream = File.OpenRead(ReportSource + "\" + reportName + ".rdl")
definition = New [Byte](stream.Length) {}
stream.Read(definition, 0, CInt(stream.Length))
stream.Close()
rs.CreateReport(reportName, parentPath, False, definition, Nothing)
Console.WriteLine("Report: {0} published successfully.", reportName)
CATCH e As Exception
Console.WriteLine("ERROR while Publishing report: " + reportName)
THROW e
END TRY
End Sub