Yaba_Middle
Yaba_Middle

Reputation: 57

Using rs.exe to run a parameter report on report server

I have a situation when I am trying to run a rs.exe to run my report (with parameter).

I am using this bat script below:

"\\server\R\subfolder\working\app\rs.exe" -i \\server\R\subfolder\working\inputfile\coo.rss -s "http://server/ReportServer_MSSQLSERVER2" -v FILENAME="\\server\R\subfolder\working\inputfile\file.csv" -v REPORTSERVER_FOLDER="/FILE_REPORT/FILE" -v Inputfile='DocType' -t  -v FORMAT="EXCEL" -e Exec2005

In the above bat script (names coo.bat), I hard coded report parameter (which isInputfile='DocType) and I then referenced this in report service script below:

 Public Sub Main()

 Dim separators As String = " "
 Dim Commands As String = Microsoft.VisualBasic.Command()
 DIm inputid As string
 Dim args() As String = Commands.Split(separators.ToCharArray)
 Dim argcount As Integer = 0
 For Each x As String In args
 argcount += 1
 Next
inputid = args(0).ToUpper

    TRY

     DIM deviceInfo as string = Nothing
     DIM extension as string = Nothing
     DIM encoding as string
     DIM mimeType as string = "application/Excel"
     DIM warnings() AS Warning = Nothing
     DIM streamIDs() as string = Nothing
     DIM results() as Byte

     rs.Credentials = System.Net.CredentialCache.DefaultCredentials
     rs.LoadReport(REPORTSERVER_FOLDER, inputid)

     results = rs.Render(FORMAT, deviceInfo, extension, mimeType, encoding, warnings, streamIDs)

     DIM stream As FileStream = File.OpenWrite(FILENAME)
     stream.Write(results, 0, results.Length)
     stream.Close()

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

But, whenever I execute the coo.bat, I keep getting :Unhandled exception:The parameter value provided for 'snapshotID' does not match the parameter type.

I will appreciate your inputs.

Upvotes: 0

Views: 1765

Answers (1)

Yaba_Middle
Yaba_Middle

Reputation: 57

I finally found the solution. Please see the edited code

Public Sub Main()

 Dim separators As String = " "
 Dim Commands As String = Microsoft.VisualBasic.Command()
 Dim args() As String = Commands.Split(separators.ToString)
'Report Parameters
 Dim parameters(1) As ParameterValue
 parameters(0) = New ParameterValue()
 parameters(0).Name = "Inputfile"
 parameters(0).Value =Inputfile


    TRY
     DIM historyID as string = Nothing
     DIM deviceInfo as string = Nothing
     DIM extension as string = Nothing
     DIM encoding as string
     DIM mimeType as string = "application/Excel"
     DIM warnings() AS Warning = Nothing
     DIM streamIDs() as string = Nothing
     DIM results() as Byte

     rs.Credentials = System.Net.CredentialCache.DefaultCredentials
     rs.LoadReport(REPORTSERVER_FOLDER,historyID )
     rs.SetExecutionParameters(parameters, "en-us")
     results = rs.Render(FORMAT, deviceInfo, extension, mimeType, encoding, warnings, streamIDs)

     DIM stream As FileStream = File.OpenWrite(FILENAME)
     stream.Write(results, 0, results.Length)
     stream.Close()

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

Upvotes: 1

Related Questions