all groups > sql server reporting services > september 2004 >
You're in the

sql server reporting services

group:

Changing programmatically the datasource of a report


Changing programmatically the datasource of a report CalinV
9/3/2004 2:53:05 PM
sql server reporting services:
I am having the following problem:
I have a shared data source and a report on the server.
I want to change the data source of the report programmatically but I am
receiving the following error:
“The required field DataSource is missing from the input structure”
I am using the following code:
Dim reference As New ReportServer.DataSourceReference
reference.Reference = "/MyDS"

Dim dss As New ReportServer.DataSource

dss.Item = CType(reference,
ReportServer.DataSourceDefinitionOrReference)
dss.Name = "MyDS"
Dim dsList() As ReportServer.DataSource = New
ReportServer.DataSource(1){}
dsList(1) = dss
dsList(1).Name = "MyDS"
rs.SetReportDataSources("/Test report1", dsList)

The shared datasource and the report are on the root directory and the
report was created with a shared datasource with the name “MyDS”
What could be the problem?

Re: Changing programmatically the datasource of a report Lev Semenets [MSFT]
9/4/2004 9:33:10 PM
where is a value for dsList(0) ?

--
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

Re: Changing programmatically the datasource of a report Henry Wang
10/26/2004 10:21:31 AM
Hi, Dear All,

I have the same problem when I tried to use setDataSource method.

Here is my code:
Dim reference As New DataSourceReference

reference.Reference = "/xxxx/" + DBName

Dim dataSources(1) As DataSource

Dim ds As New DataSource

ds.Item = CType(reference, DataSourceDefinitionOrReference)

ds.Name = DBName

dataSources(0) = ds

' Render arguments

Dim reportPath As String = "/xxx/yyy" +
Request.Params("NumberOfT").ToString()

Dim format As String = "PDF"

Dim historyID As String = Nothing

Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"

' Prepare report parameter.

Dim parameters(1) As ParameterValue

parameters(0) = New ParameterValue

parameters(0).Name = "ReportID"

parameters(0).Value = Request.Params("ReportID").ToString()

parameters(1) = New ParameterValue

parameters(1).Name = "xxx"

parameters(1).Value = Request.Params("xxx").ToString()

Dim rs As New ReportingService

rs.Credentials = System.Net.CredentialCache.DefaultCredentials

rs.SessionHeaderValue = New SessionHeader

rs.SetReportDataSources(reportPath, dataSources) (error happend here)

Actually, I copied it from MSDN sample. I did not see how the DataSources(1)
could be set. Do I need to set DataSources(1)?



Thanks,



Henry

[quoted text, click to view]

Re: Changing programmatically the datasource of a report Lev Semenets [MSFT]
10/28/2004 11:06:45 PM
I think it should be

Dim dataSources(0) As DataSource
instead of
Dim dataSources(1) As DataSource

Please let me know if this works for you.

--
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

Re: Changing programmatically the datasource of a report Eddie
11/3/2004 2:24:04 PM
On kinda same vien, I generate a RDL with a shared datasource. Once
published, it says the datasource is no longer valid. Any advice?

[quoted text, click to view]
Re: Changing programmatically the datasource of a report Lev Semenets [MSFT]
11/4/2004 10:17:24 PM
Could you email me the code?

--
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

Re: Changing programmatically the datasource of a report Eddie
11/5/2004 7:43:03 AM
I got it, phew.
I tried a couple of things, to make sure it wasn't a bug. First I used a
known working RDL template, which uses a shared datasource. I deleted a node
and put it back in and and published it. I went ahead and set the datasource
to the newly published report. That seems to work, but I still wonder why it
doesn't work as seamless as when publishing from the Designer.
[quoted text, click to view]
Re: Changing programmatically the datasource of a report Lev Semenets [MSFT]
11/5/2004 9:38:29 PM
Designer does more than just uploading a report.

--
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

AddThis Social Bookmark Button