Quantcast
Viewing latest article 6
Browse Latest Browse All 24

Deploying Reports rss (however cannot get shared datasource to work)

Hi,

Here is the code i am using the deploy the datasources and report.
the code does work correctly, however in the reports that were depending on a shared datasource.. that link somehow and for some reason is broken

In the original deployment (from the visual studio project) the shared datasources are in the exact "path/name" as i am creating below.
however, i would have to manually goto each report and relink the share datasource.
because in the report datasource, i see this error
    "The shared data source reference is no longer valid"

as you can see below i tried both methods
  rs.CreateDataSource(name, "/Data Sources", True, definition, Nothing)  
  rs.SetDataSourceContents("/Data Sources/" + name, definition)
even thought they are created in the right place, they arent.... "shared" or linked as far as the reports are concerned.
where am i going wrong?
thanks



Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing
Dim DestinationFolder As String = "Reports"
Dim DestinationSources As String = "Data Sources"
Dim parentPath As String = "/" + DestinationFolder
Dim ReportSource As String

Public Sub Main()   
TRY

    Console.WriteLine("")
    Console.WriteLine("----< Deploying. >----")
    Console.WriteLine("")

   ReportSource = "C:\Program Files\****\Reports"
   
     rs.Credentials = System.Net.CredentialCache.DefaultCredentials     
    
    If rs.GetItemType("/Reports") = Microsoft.SqlServer.ReportingServices2005.ItemTypeEnum.Folder Then
     rs.DeleteItem("/Reports")
    End If
    rs.CreateFolder("Reports", "/", Nothing)              
    Console.WriteLine("Parent folder [Reports] created successfully.")
      
    If rs.GetItemType("/Data Sources") = Microsoft.SqlServer.ReportingServices2005.ItemTypeEnum.Folder Then
     rs.DeleteItem("/Data Sources")
    End If
    rs.CreateFolder("Data Sources", "/", Nothing)              
    Console.WriteLine("Parent folder [Data Sources] created successfully.")
   

    CreateReportDataSource("PDataSet", "SQL", "Data Source=localhost;Initial Catalog=****")  
    CreateReportDataSource("DBConn", "DATASET", "Data Source=localhost;Initial Catalog=*****")  
    Console.WriteLine("")
    Console.WriteLine("----< DataSources Deployed. >----")
    Console.WriteLine("")
                                            
    PublishReport("Main Search")
 
    Console.WriteLine("")
    Console.WriteLine("----< Reports Deployed. >----")
    Console.WriteLine("")

CATCH  ex As Exception
   THROW ex
END TRY
End Sub

Public Sub CreateReportDataSource(name As String, extension As String, connectionString As String)
    'Data source definition.
    Dim definition As New DataSourceDefinition()
    definition.CredentialRetrieval = CredentialRetrievalEnum.Store
    definition.ConnectString = connectionString
    definition.Enabled = True
    definition.Extension = extension
    'definition.ImpersonateUserSpecified = True
    definition.WindowsCredentials = False
    definition.UserName = "****"
    definition.Password = "****"
 

 TRY
  rs.CreateDataSource(name, "/Data Sources", True, definition, Nothing)  
  rs.SetDataSourceContents("/Data Sources/" + name, definition)

     Console.WriteLine("Source: {0} created successfully.", name)
 CATCH e As Exception
  Console.WriteLine("ERROR creating data source: " + name)
  THROW e
 END TRY
 
End Sub

Public Sub PublishReport(ByVal reportName As String)
TRY
    Dim stream As FileStream = File.OpenRead(ReportSource + "\" + reportName + ".rdl")
    definition = New [Byte](stream.Length) {}
    stream.Read(definition, 0, CInt(stream.Length))
    stream.Close()
 
 
    rs.CreateReport(reportName, parentPath, False, definition, Nothing)
    Console.WriteLine("Report: {0} published successfully.", reportName)      
CATCH e As Exception
 Console.WriteLine("ERROR while Publishing report: " + reportName)
 THROW e
END TRY





End Sub


Viewing latest article 6
Browse Latest Browse All 24

Trending Articles