VB RS.exe - 未定义数据源



我有这段代码以编程方式将报告导出为 PDF。

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
Dim dataSources() As DataSource = rs.GetItemDataSources("foldername/reportname")
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

当我运行它时,我收到一个错误,说:

error BC30002: Type 'DataSource' is not defined.
Dim dataSources() As DataSource = rs.GetItemDataSources("foldername/reportname")
~~~~~~~~~~

我忘记导入东西了吗?如果我删除该行,它可以正常工作(除此之外,它需要添加数据源(。事先添加数据源不是一种选择。

所以我想出了答案。我正在使用Exec2005(执行端点(,其中不包括DataSource的定义。我应该改用默认端点(Mgmt2005(,但这会导致代码中的其他问题。

无论如何,这个问题的答案是 不要使用-e Exec2005.

最新更新