hi,
Thx. in advance.
How can I Associate DataSource with Report using Code.I'm using Reporting
Service Web Serivice
I tried this below code but it is giving error
like
"The data source 'DS_Code_002' cannot be found in this report. --> The data
source 'DS_Code_002' cannot be found in this report"
DataSourceReference reference = new RS.DataSourceReference();
reference.Reference = txtDSPath.Text;
DataSource[] dataSources = new RS.DataSource[1];
DataSource ds = new RS.DataSource();
ds.Item = (RS.DataSourceDefinitionOrReference) reference;
ds.Name = txtDSPath.Text.Substring(txtDSPath.Text.LastIndexOf("/")+1);
dataSources[0] = ds;
rs.SetReportDataSources(txtReportPath.Text, dataSources);
Please help me to resolve the issue.
Thx. again.
regards,
Krishna.MIt took me 2 months to code this after hounding people and digging through
books. I look back and shake my head... :)
Note: FolderPath is the path of where the report root lives... i.e. if your
report was here and called "Top 50 Financial Statements" then the full path
is:
/reports/business/quarterly/Top 50 Financial Statements
and ReportRoot = "/reports/business/quarterly"
RSReports is my reference to the Reporting Service WSDL file (the variable
name you create when reference the reporting services web service)
MyDatasourceName is the name of your datasource. Be sure you specify where
it is exactly. :)
rsDeliverTo is just a variable of RSReports.ReportingService i.e.
Dim rsDeliverTo as RSReports.ReportingService
You should use "rsDeliverTo" to programmatically create your report, so you
can set the datasource in the code below as I have outlined:
Dim reference As New DataSourceReference
reference.Reference = ReportRoot & "/MyDatasourceName"
Dim ReportPathToReport As String = FolderPath + "/" + name
Dim rds() As RSReports.DataSource =rsDeliverTo.GetReportDataSources(ReportPathToReport)
Dim bflag As Boolean = False
Dim strResult As String = ""
For i As Integer = 0 To rds.Length - 1
If TypeOf rds(i).Item Is RSPolarisReports.InvalidDataSourceReference Then
rds(i).Item = CType(reference, DataSourceDefinitionOrReference)
bflag = True
End If
Next i
If (bflag) Then
rsDeliverTo.SetReportDataSources(ReportPathToReport, rds)
End If
Now that you have that, you can then proceed to set the report timeouts,
caching options, etc.
=-Chris
"Krishna kumar.M" <Krishna kumar.M@.discussions.microsoft.com> wrote in
message news:29C00F28-6ED1-4B1B-9BF6-9AFFB8C1CDD6@.microsoft.com...
> hi,
> Thx. in advance.
> How can I Associate DataSource with Report using Code.I'm using Reporting
> Service Web Serivice
> I tried this below code but it is giving error
> like
> "The data source 'DS_Code_002' cannot be found in this report. --> The
> data
> source 'DS_Code_002' cannot be found in this report"
>
> DataSourceReference reference = new RS.DataSourceReference();
> reference.Reference = txtDSPath.Text;
> DataSource[] dataSources = new RS.DataSource[1];
> DataSource ds = new RS.DataSource();
> ds.Item = (RS.DataSourceDefinitionOrReference) reference;
> ds.Name = txtDSPath.Text.Substring(txtDSPath.Text.LastIndexOf("/")+1);
> dataSources[0] = ds;
> rs.SetReportDataSources(txtReportPath.Text, dataSources);
>
> Please help me to resolve the issue.
> Thx. again.
> regards,
> Krishna.M
Wednesday, March 21, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment