none
How to deploy a RDL file using rs.exe?

    Question

  • Hi all,

    I would like to deploy a data source (.rds) file to SSRS like I already do with report files (.rdl):

    Public Sub PublishReport(ByVal reportName As String)
        Try
            Dim stream As FileStream = File.OpenRead(filePath + reportName + ".rdl")
            definition = New [Byte](stream.Length) {}
            stream.Read(definition, 0, CInt(stream.Length))
            stream.Close()
    
        Catch e As IOException
            Console.WriteLine(e.Message)
        End Try
    
        Try
            warnings = rs.CreateReport(reportName, parentPath, False, definition, Nothing)
    
            If Not (warnings Is Nothing) Then
                Dim warning As Warning
                For Each warning In warnings
                    Console.WriteLine(warning.Message)
                Next warning
    
            Else
                Console.WriteLine("Report: {0} published successfully with no warnings", reportName)
            End If
    
        Catch e As Exception
            Console.WriteLine(e.Message)
        End Try
    End Sub 
    



    That method is used by the reporting service samples. There is also a method offered by Reporting Service to create a data source, but the definition is an element of "DataSourceDefinition" and not a stream like used for CreateReport. How can I deploy a .rds file or is it only possible to read the file and set the information into a "DataSourceDefinition" ?
    Thanks for your help,

    Michael

     

    Tuesday, August 04, 2009 7:19 AM

Answers

  • Hi Michael,

    We can use the CreateDataSource method to create a datasource:


    Of course, we can the FileStream to read the datasoure's information from the RDS file.

    For more information about CreateDataSource, please see:
    http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.createdatasource.aspx

    Please feel free to ask, if you have any more questions.

    Thanks,
    Jin Chen

    Public Sub Main()
          Dim rs As New ReportingService2005()
          rs.Credentials = System.Net.CredentialCache.DefaultCredentials
    
          Dim name As String = "AdventureWorks"
          Dim parent As String = "/"
    
          ' Define the data source definition.
          Dim definition As New DataSourceDefinition()
          definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated
          definition.ConnectString = "data source=(local);initial catalog=AdventureWorks"
          definition.Enabled = True
          definition.EnabledSpecified = True
          definition.Extension = "SQL"
          definition.ImpersonateUserSpecified = False
          'Use the default prompt string.
          definition.Prompt = Nothing
          definition.WindowsCredentials = False
    
          Try
             rs.CreateDataSource(name, parent, False, definition, Nothing)
    
          Catch e As SoapException
             Console.WriteLine(e.Detail.InnerXml.ToString())
          End Try
       End Sub 'Main

     


    Jin Chen - MSFT
    Wednesday, August 05, 2009 8:24 AM
  • Here is how we solve that same problem. We develop the reports to use shared data sources. Those same datasources are in each environment pointing to the appropriate DB for that environment. Now we just deploy the report to dev, test, Prod and the shared data source already points to the correct location. But then I don't know how your environments are set up that might not be feasible for you but just an idea.
    Thursday, August 06, 2009 3:34 PM
  • Hi Michael,

    I think I've found a way you can do this.
    There's a (free) windows forms utility called RSScripter that basically acts as a front end to rs.exe
    Find it at:
    http://www.sqldbatips.com/showarticle.asp?ID=62

    There's also a command line component to this as well: RSScripterCmd.exe.

    If you look in the readme file (http://www.sqldbatips.com/samples/code/RSScripter/readme.htm )

    Section "5.2 Input Parameters for RSScripterCmd.exe"
    Parameter "ld" says:

    "When this parameter is specified and set to True then scripting options are ignored and RDL and RDS files in a source folder (specified by the /sf parameter) are directly uploaded to a target Report Server folder (specified by the /tf parameter)"

    An example is in "Section 5.4 Usage Notes..." :

    Example #7 In the example below we are specifying the required parameter (/s ) and seting the /ld parameter to True (meaning that we want to load files from the filesystem rather than run scripts). Because we have set /ld to True we need to specify the source (/sf ) and target (/tf ) folders. In this example we are loading files from C:\Report Project to the nested Uploaded Reports Report Server folder. Note that we are using an alias defined in the servers.xml file rather than specifying the full url for the source Report Server

    rsscriptercmd /s:SQL2005 /ld:True /sf:"C:\Report Project" /tf:"/Main Report Project/Uploaded Reports"
    
    
    

    I haven't tried it yet, but thought I'd let you know anyway.
    Also, I asked the author of the tool (Jasper Smith) a question and got a very quick response.

    Hope it helps,
    Peter.





    Wednesday, August 19, 2009 8:52 AM

All replies

  • You need to have a RSS script, which publishes a RDL file on the server. You create a RSS script, what you can do is, publish any report on the server using the Management Studio. Before you finally click the OK button, make use of 'Script Action to New Query Window'. This will generate all the code required to publish a report on SSRS. This is similar to recording a macro in Excel.

    Once the RSS file is created, you can customize it as per your requirement...i.e report file name, file path, etc. Then you can call this rss file using rs.exe. Here's the syntax:

    rs -i "InputFileName" -s "ServerURL" -u "Username" -p "password" -v Variable1="Value1"... Variablen="Valunen"

    You may or may not use the last parameter '-v'. This could be used for passing your report filename or path and so on

    Hope this helps.

    Regards,

    [P]

    Microsoft Techie
    • Proposed as answer by Gouri SohoniMVP Tuesday, August 04, 2009 9:26 AM
    • Unproposed as answer by Michael_Rue Tuesday, August 04, 2009 1:13 PM
    Tuesday, August 04, 2009 8:49 AM
  • Hi [P]

    the problem is not the command or creating a rss-script, because I already have one which works for reports. I'm just looking for the method/part that I have to use in the script to deploy the rds. I do not have the permissions to login to the server to use the Management Studio, only the remote deploy rights are served.
    I thought it might exist a method to publish DataSources like the one I posted to publish reports.
    Thanks for your help,

    Michael
    Tuesday, August 04, 2009 1:12 PM
  • Hi Michael,

    We can use the CreateDataSource method to create a datasource:


    Of course, we can the FileStream to read the datasoure's information from the RDS file.

    For more information about CreateDataSource, please see:
    http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.createdatasource.aspx

    Please feel free to ask, if you have any more questions.

    Thanks,
    Jin Chen

    Public Sub Main()
          Dim rs As New ReportingService2005()
          rs.Credentials = System.Net.CredentialCache.DefaultCredentials
    
          Dim name As String = "AdventureWorks"
          Dim parent As String = "/"
    
          ' Define the data source definition.
          Dim definition As New DataSourceDefinition()
          definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated
          definition.ConnectString = "data source=(local);initial catalog=AdventureWorks"
          definition.Enabled = True
          definition.EnabledSpecified = True
          definition.Extension = "SQL"
          definition.ImpersonateUserSpecified = False
          'Use the default prompt string.
          definition.Prompt = Nothing
          definition.WindowsCredentials = False
    
          Try
             rs.CreateDataSource(name, parent, False, definition, Nothing)
    
          Catch e As SoapException
             Console.WriteLine(e.Detail.InnerXml.ToString())
          End Try
       End Sub 'Main

     


    Jin Chen - MSFT
    Wednesday, August 05, 2009 8:24 AM
  • Hi,

    Check this link

       http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/87b26ad4-2df3-4da2-9f3c-7b9721b28ca7/

    I hope this link might be helpful
    Rajesh Jonnalagadda http://www.ggktech.com
    Wednesday, August 05, 2009 8:35 AM
  • Hi,

    maybe I'm blind, but I don't see how this may help me, because you define datasource inside your script. But I get some rdl files and a rds file from the developer to deploy it. The reports are no problem, but I haven't found a solution to deploy a datasource by getting the information out of the rds file.

    The settings could change throughout the different deployments, because they are used for tests in different environments.

    Thanks for your help,

    Michael

    Wednesday, August 05, 2009 9:38 AM
  • Here is how we solve that same problem. We develop the reports to use shared data sources. Those same datasources are in each environment pointing to the appropriate DB for that environment. Now we just deploy the report to dev, test, Prod and the shared data source already points to the correct location. But then I don't know how your environments are set up that might not be feasible for you but just an idea.
    Thursday, August 06, 2009 3:34 PM
  • Hi Michael,

    I think I've found a way you can do this.
    There's a (free) windows forms utility called RSScripter that basically acts as a front end to rs.exe
    Find it at:
    http://www.sqldbatips.com/showarticle.asp?ID=62

    There's also a command line component to this as well: RSScripterCmd.exe.

    If you look in the readme file (http://www.sqldbatips.com/samples/code/RSScripter/readme.htm )

    Section "5.2 Input Parameters for RSScripterCmd.exe"
    Parameter "ld" says:

    "When this parameter is specified and set to True then scripting options are ignored and RDL and RDS files in a source folder (specified by the /sf parameter) are directly uploaded to a target Report Server folder (specified by the /tf parameter)"

    An example is in "Section 5.4 Usage Notes..." :

    Example #7 In the example below we are specifying the required parameter (/s ) and seting the /ld parameter to True (meaning that we want to load files from the filesystem rather than run scripts). Because we have set /ld to True we need to specify the source (/sf ) and target (/tf ) folders. In this example we are loading files from C:\Report Project to the nested Uploaded Reports Report Server folder. Note that we are using an alias defined in the servers.xml file rather than specifying the full url for the source Report Server

    rsscriptercmd /s:SQL2005 /ld:True /sf:"C:\Report Project" /tf:"/Main Report Project/Uploaded Reports"
    
    
    

    I haven't tried it yet, but thought I'd let you know anyway.
    Also, I asked the author of the tool (Jasper Smith) a question and got a very quick response.

    Hope it helps,
    Peter.





    Wednesday, August 19, 2009 8:52 AM
  • Hi Michael,

    The CreateDataSource  is used to create a datasource in the Report Server.

    There is no way to upload the .RDS directlly. But the .RDS is a standard XML file, we can:
    1.Use filestream to open the file
    2.Read the configuration information from the file.
    3.Use the CreateDataSource  and the information we have got in step2 to create a datasource.

    Please feel free to ask, if you have any more questions.

    Thanks,
    Jin Chen


    Jin Chen - MSFT
    Friday, August 21, 2009 9:28 AM
  • Hi {P},

    "You need to have a RSS script, which publishes a RDL file on the server. You create a RSS script, what you can do is, publish any report on the server using the Management Studio. Before you finally click the OK button, make use of 'Script Action to New Query Window'. This will generate all the code required to publish a report on SSRS. This is similar to recording a macro in Excel."

    I wonder how you can open a SSRS project in SSMS.  Are you refering BIDS.  If it is possible could you please provide some pointer.  Also I could not able to locate the script out option.

    Tuesday, October 19, 2010 10:30 AM