0

我有这个代码以编程方式将报告导出为 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")
                      ~~~~~~~~~~

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

4

1 回答 1

0

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

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

于 2018-08-21T12:34:56.297 回答