Click here to Skip to main content
15,911,896 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all,
I need to publish reports from my system C:drive to report server http://172.16.11.161/reportserver target folder.
Here is the code that i have written publishreports.rss.No result is coming i execute the batch file
I need any permissions to publish reports in reportserver?
PublishReports.rss

Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing
Dim parentPath As String = "/" + parentFolder
Dim filePath As String = "C:\Deployment\Anguss_Reports\"
Public Sub Main()
    rs.Credentials = System.Net.CredentialCache.DefaultCredentials
    Dim name As String
    'Create the parent folder
    Try
        rs.CreateFolder(parentFolder, "/", Nothing)
        Console.WriteLine("Parent folder created: {0}", parentFolder)
    Catch e As Exception
        Console.WriteLine(e.Message)
    End Try
    CreateSampleDataSource()
    
    PublishReport("R1")
End Sub
Public Sub CreateSampleDataSource()
    Dim name As String = "AngussDatasource"
    Dim parent As String = "/" + parentFolder
    'Define the data source definition.
    Dim definition As New DataSourceDefinition()
    definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated
    definition.ConnectString = "data source=(10.10.10.86);initial catalog=Silvanus_Dev"
    definition.Enabled = True
    definition.EnabledSpecified = True
    definition.Extension = "SQL"
    definition.ImpersonateUser = False
    definition.ImpersonateUserSpecified = True
    'Use the default prompt string.
    definition.Prompt = Nothing
    definition.WindowsCredentials = False
Try
    rs.CreateDataSource(name, parent, False, definition, Nothing)
Catch e As Exception
    Console.WriteLine(e.Message)
End Try
    
End Sub 
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 

Batchfile text

rs -i Publishreports.rss -s http://172.16.11.161/ReportServer -v parentFolder="Silvanus_lots"

Please clarify me thanks in advance.
Balu.
Posted
Updated 6-Jun-11 4:20am
v2

1 solution

You must have Content Manager rights on the folder specifically or on SSRS server, to publish reports.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900