Search code examples
vb.netreporting-servicesssrs-2008rs.exe

VB RS.exe - DataSource is not defined


I have this code to programmatically export a report to 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

When I run it I get an error saying:

error BC30002: Type 'DataSource' is not defined.

 Dim dataSources() As DataSource = rs.GetItemDataSources("foldername/reportname")
                      ~~~~~~~~~~

Am I forgetting to import something? If I remove that line it works fine (besides that it needs a data source to be added). Adding the data source beforehand is not an option.


Solution

  • So I figured the answer. I am using the Exec2005 (execution endpoint), which does not include the definition for DataSource. I should instead use the default endpoint (Mgmt2005), but this causes other problems in the code.

    In any case, the answer to this question is to not use -e Exec2005.