Pro SQL Server 2012 Reporting Services

(sharon) #1

CHAPTER 8  DEPLOYING REPORTS


Try
' Create the datasource through the web service method
rs.CreateDataSource(name, "/" + parentPath, False, dataSourceDefinition, Nothing)

' Diplay success message on creation
Console.WriteLine("Data source {0} created successfully", name)
Catch e As Exception
' If the creation failed, catch execption and display the result
Console.WriteLine(e.Message)
End Try

End Sub

Public Sub DeployReport(ByVal reportName As String)

Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing

Try
' Attempt to open the report as a file stream to read report definition information
Dim stream As FileStream = File.OpenRead(reportPath + reportName + ".rdl")
definition = New [Byte](stream.Length) {}
stream.Read(definition, 0, CInt(stream.Length))
stream.Close()

Try
' Attempt to deploy the reportvia the web service
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

Catch e As IOException
Console.WriteLine(e.Message)
End Try

End Sub
Free download pdf