我有一种情况,我在报告服务器中有一个已部署的rdl文件。有问题的rdl文件有一个参数。
我正在使用rs.exec组件来执行报告;每当我从rdl文件中删除参数时,我都成功地从存储过程运行报告。当我添加参数时,我不断得到的是
\\server\R\subfolder\working\inputfile\example.batK00WE is not recognized as an internal or external operable program or batch file.
这是我做的:我在VB中创建了一个.rss文件(请参阅下面的代码)
Public Sub Main()
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)
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
之后......我写了一个使用rs.exec的批处理文件。请参阅以下内容:
"\\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" -t -v FORMAT="EXCEL" -e Exec2005
如果您看到上面的脚本,则rs.exec使用报表服务器的路径等。
最后,我创建了一个存储过程,它将在服务器上运行报告并将参数值传递给服务器。
CREATE PROCEDURE [dbo].[test_sproc]
@ProcessID varchar(50)
AS
DECLARE @cmdsql varchar(1000)
Declare @id varchar(50)
Set @id=@SID
Set @cmdsql= '"\\server\R\subfolder\working\inputfile\example.bat"' + @id
exec master..xp_CMDShell @cmdsql
所以我的问题是:如何将参数值从存储过程传递到报表服务器?我的代码在哪里出错?