October 19, 2007 at 12:30 pm
Hi all,
I am trying to use PublishReports.RSS with rs.exe and it ends in error like
parentfolder not declare
Dim parents as string = '/' + parentfolder
I have used following command in cmd prompt:
rs.exe -i c:\test.rss -s http:\\servername\reportserver -v filapath = "C:\reports" -v sqlServerName="servername" -v parentfolder="Test"
Here is the script that i have used
____________________________________________________________________________________________________
Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing
Dim parentPath As String = "/" + parentFolder
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
CreateHOSDataSource(sqlServerName)
PublishReport("Report1")
PublishReport("Report2")
End Sub
Public Sub CreateHOSDataSource(ByVal sqlServerName As String)
Dim name As String = "DataSource1"
Dim parent As String = "/" + parentFolder
'Define the data source definition.
Dim definition As New DataSourceDefinition()
definition.CredentialRetrieval = CredentialRetrievalEnum.Store
definition.ConnectString = "data source=" & sqlServerName & ";initial catalog=DB1"
definition.Enabled = True
definition.EnabledSpecified = True
definition.Extension = "SQL"
definition.ImpersonateUser = False
definition.ImpersonateUserSpecified = True
definition.WindowsCredentials = False
definition.UserName = "SomeUser"
definition.Password = "somepassword"
Try
rs.CreateDataSource(name, parent, True, 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, True, 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
October 20, 2007 at 8:10 pm
Could be a typo on your post but I'm guessing it could be case sensitivity on the param name that you pass using -v.
you wrote
-v parentfolder="Test"
(note the lowercase F) yet your code refers to parentFolder (note the caps F)
Dim parentPath As String = "/" + parentFolder
Public Sub Main()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim name As String
'Create the parent folder
Try
rs.CreateFolder(parentFolder, "/", Nothing)
Steve.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply