Tuesday 14 February 2006

SQL Server Reporting Services RS.EXE (#1)

Automating the deployment of reports (*.rdl) and data sources (*.rds) using NAnt and RS Utility (rs.exe) has been relatively straight forward. There are a few tricks, which I'll post later; but for now, the following error had me stumped for a while, and didn't return anything useful on Google.

The required field DataSource is missing from the input structure

In my case, I tracked it down to sample code I'd copied from
MSDN: ReportingService.SetReportDataSources.

I'm using VB.NET (argh!), and the dataSources array declaration in this sample code is the cause of the error.
Dim dataSources(1) As DataSource
actually creates a two-element array BUT we only set one element
dataSources[0] = ds;
so when this line executes
rs.SetReportDataSources("/SampleReports/Product Catalog", dataSources)
it is actually sending an array where the zeroth element is set to a valid object, but the first element is NULL... hence the (somewhat cryptic) "required field DataSource is missing" error.

The fix?
Dim dataSources(0) As DataSource

No comments:

Post a Comment

Note: only a member of this blog may post a comment.