Click here to Skip to main content
Click here to Skip to main content

A helper object to migrate SQL Reporting Service items

By , 10 Sep 2004
 

Introduction

There are two main pieces of code in the solution: a helper object (maSQLReport), and a test form that uses the object to do its work. Please note that the test application (which can be downloaded as an EXE) has almost no exception handling, and is very crude. Its function was only to allow me to test prior to integration into our existing migration tool.

Background

Our company supports an ASP/ASP.NET business application. Currently, this application uses Crystal Reports for reporting, but we are investigating SQL Reporting. Our development process has us do development and unit testing on a development server, migration and acceptance testing on a staging server, and production and training each on a dedicated server.

We already have written a tool which moves the ASP pages, SQL Procs, and crystal .RPT files for each development issue along the migration path. The goal of this object was to integrate similar migration of SQL Reports using the Reporting Services SOAP API. As such, some of the choices for public interfaces for maSQLReport are based on the needs we had in that application - such as exposing the available items in a tree.

Using the Test Application

Sample Image - maSQLReport.jpg

The demo simply tests the public interfaces of the helper object. It could serve as a guide to integrating the object into your own work.

To use:

  1. Set the WSDL path to the report servers in the "Source" and "Destination" input boxes. I have pre-filled them with an example for the default location and name.
  2. Click the "SetURL" button. (If you are compiling the code, if you change the defaults, this won't be necessary.)
  3. Click on "Load Tree". This will show you all items from the root of your source server. (Note that walking the folder tree via the web service is slow - if you have a lot of nested folders, this could take a while. You might want to change the getReportTree call to start in a sub-folder.)
  4. The Select button will move the selected tree item into the ListView below, the DeSelect button will remove selected items from the ListView.
  5. Clicking the "Migrate" button will move items from the source server to the destination server.
    1. Shared DataSources and Linked Reports will not be overwritten if they exist.
    2. Most parent items will be created if they don't exist - such as:
      1. Source Reports for a Linked Report
      2. Shared DataSources
      3. Shared Schedules for execution, history, or snapshots
      4. Security is not migrated
      5. Subscriptions are not migrated
    3. If a report is set to render from a snapshot, but there is no schedule for the snapshot, a snapshot will be taken.
    4. If a report has a subreport, the subreport will not be automatically migrated.
  6. Output results will appear in the ListBox to the right. You may clear it with the "Clear" button.

Using the helper object

First, instantiate an instance of the object. If you wish to set the paths at run-time, just set them to empty strings; as long as the property is set prior to making a call, it is fine.

 Dim maSQLRep As New maSQLReport.Reports("", "", "", "", 1, 2, 3, 4, 5, 6)

This takes the following input:

DevURL As String, StageURL As String, TrainURL As String, _
 LiveURL As String, ResourceImageIndex As Integer, ReportImageIndex As Integer, _
 DataSourceImageIndex As Integer, LinkReportImageIndex As Integer, _
 ClosedFolderImageIndex As Integer, OpenfolderImageIndex As Integer 

The xxxURL Strings are the WSDL paths to each server. The ImageIndexs are the image index of a ImageList object that has the images to use in a TreeView defined in your program.

maSQLReport exposes the helper object, Reports, as well as the actual SOAP API, as SQLReportingServices.

Object Definition:

maSQLReport.Reports exposes four public interfaces, as well as four properties, an Enum, and a class. They are:

  1. The properties are the same as the first four parameters to New:
    • DevURL
    • StageURL
    • TrainURL
    • LiveURL
  2. The Enum
    • SeverityLevels - defines severity of error messages output by the migration.
  3. The Class
    1. RSItemNode - an overloaded version of Windows.Forms.TreeNode. This is what the getTreeNode method returns.
    2. In addition to the regular Treenode method/properties, this also exposes:
      • Item - is the SQLReportingServices.CatalogItem the node is based on.
      • Tag - is populated with a ListViewItem containing the path, a type description, and the source URL as SubItems.
  4. The Methods:
    • getReportTree - Takes the starting path and an optional String for the root NodeName.
    • MigrateDev2Stage - takes a fully qualified item path, and moves that item from the server defined in devURL to the server defined in StageURL.
    • MigrateStage2Train - same as above, from StageURL to TrainURL.
    • MigrateStage2Live - same, from StageURL to LiveURL.

Example Uses:

Setting the URLs from a textbox:

maSQLRep.DevURL = txtSourceURL.Text
maSQLRep.StageURL = txtDestinationURL.Text

Getting the contents of the source server as a TreeNode:

'Assume TreeView1 is a TreeView, that has an imageList set
'returned nodes will have imageindexs set to match the defined indexes from object
'instantiation.
TreeView1.Nodes.Add(maSQLRep.getReportTree("/"))
'If path specified, would start there

Using info from a selected TreeNode:

'Populating a listview - if it is in detail mode, and has 3 columns
'with subitem information already loaded 
'
ListView1.Items.Add(TreeView1.SelectedNode.Tag)
'Could also read any of the CatalogItem properties by casting to RSItemNode
Dim rsNode As maSQLReport.Reports.RSItemNode = TreeView1.SelectedNode
Dim path As String = rsNode.Item.Path

Migrating an item and displaying the results:

Dim warnings As New ArrayList 
'All Items in a listview, place output in a listbox 
For Each item As ListViewItem In ListView1.Items 
    warnings.AddRange(maSQLRep.MigrateDev2Stage(item.Text)) 
    If Not warnings Is Nothing Then 
        For Each warning As maSQLReport.SQLReportingServices.Warning In warnings
            ListBox1.Items.Add(warning.Message) 
        Next 
    End If 
    warnings.Clear() 
Next
'A single item found from casting example
warnings = maSQLRep.MigrateDev2Stage(path)

Point of Interest

At this time, there is no provision to migrate server settings, such as roles/item security, or subscriptions. Our need was just to move the actual Catalog items.

If there is interest, I will do a follow-up article that walks-through the actual object code.

History

Version 1.0 - Article is based on.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Mark Brandon
Software Developer (Senior)
United States United States
Member
I've been playing around with computers since I started programming in about 1979. On punch cards. (that was an Explorer program in 4th grade) I ran a BBS in the late '80s for the 4 years I was in college for the first time... but ended up in the theater department.
 
After a dropping out for a while, my flirtation with being a studio recording engineer lead to a BS in EET - after which I ended up somehow being a network admin / tech support person.
 
I then taught high school electronics for a while... before leaving for the exciting world of restaurant managment.
 
I gave it up, however, to get a second degree in IT/Software Design - and now the circle is complete, I'm back in programming; primarly ASP.NET / Classic ASP business apps.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questiondifference between enterprise edition and express editionmembervaratharajan198316 Aug '07 - 19:38 
i have problem in product version for enterprise version and express edition
 
bye
rajan
 
i have join now. i saw this website .this is good websitve.and most useful article coming in this website . i am software developer in mumbai

AnswerRe: difference between enterprise edition and express editionmemberMark Brandon21 Aug '07 - 2:57 
**WHAT** problem do you have? Does it have anything to do with using the Reporting Service API? Confused | :confused:
 
You are comparing the freely distributable (express) edition and the most expensive license (Enterprise). It should be no shock that there are differences in functionality - please read the Microsoft literature describing version features of the various SQL editions.
 
I don't know, but I would be really surprised if Express supported RS. Express is a client machine database engine to support workstation applications; it is not a server product.
 
In 2005 there is a client-side rendering object designed to let you render RDL based reports on the client, AFAIK, it does not require any SQL engine support. This object did not ship with 2000. I do not know if it became available for 2000 with the release of 2005 (but I doubt it), as I do not use that type of functionality.
 
BTW, the destination use of this object was tested against SQL Standard. While I have an install of SQL Developer (which has all Enterprise features) that I used as the source server, our production & unit/regression testing servers are only Standard. I didn't test moving a data-driven subscription, and have no way to test (or idea what this would do) if you had it running in a farm.
 

QuestionData exchane to MS-ExcelmemberRavisubrahmanya21 Jul '07 - 2:06 
Hi,
 
I want to exchange the data from SQL server to MS-Excel, it should be genarate an Report.
 
Suppose for example,
My server is SQL or MSDE server is stroing the data, that data should be copied to the Excel sheet(Automatic report genaration) in such manner that, it should be a daily report, also monthly report and yearly report.
 
For example 00:00 to 24:00 hrs one system is giving repaeated reading.i am logging in that values in my server. My server should genaarte a automatic report on Excel sheet.The data from 00:00 hr to 24:00 hr, to be genarate as a report. Each hour data should be update in the Excel sheet, and after the complition of 24 hr, report should be genarate. and in the next column of excel sheet, 01:00hr-00:00hr, 02:00-00:00hr likewise 00:00 hr data should be subtract from each hour data and the result should be stored in the another column of excel sheet for corresponding each hour and finally after 24 hours all these subtracted data of each hours should be added, and it will be the final result of that day.This will be a daily Report.
 
For monthly report all these final Results of each day will be update in excel and to be added and that result will be the Montly Report.
 
How it will be possible?. All this should happen automatically each day and each month. Please help me regarding this.
 
With regards,
Ravisubrahmnaya

Questionhow to deploy a reporting servermemberPadoor Shiras19 Jul '07 - 20:19 
can you please tell me how to deploy a reporting server through a windows application C#.
 
Shiras AbdulRahman works with Proteans Software Solutions(www.proteans.com) as senior software engineer. Proteans, a Microsoft Gold Partner is a Software Product Engineering company focused on Microsoft Technology Platform.
 

AnswerRe: how to deploy a reporting servermemberMark Brandon20 Jul '07 - 2:58 
I'm not sure what you are asking. Are you looking to install the server application, or setup/deploy reports to the application?
 
-mb
GeneralRights errorsmemberRZOE18 May '07 - 6:15 
I am getting an error "CanGenerateModel" is read-only when I try to migrate a datasource.
 
Any Ideas.Confused | :confused:
AnswerRe: Rights errorsmemberMark Brandon21 May '07 - 3:47 
Is this under 2005? I haven't tested (or made any updates for) against a 2005 server - we don't have one in place yet.
 
While I should have probably figured out a way to test if a property is read-only & not included it in the array to update, I just created a function (named RemoveROProps) that removed invalid properties by name... you will have to add this (and any other new RO props) to this function.
 

Generalsystem.web.webexceptionmemberkimmy234324322 May '07 - 2:04 
system.web.webexception: the underlying connection was closed. The remote name couldnt be resolved.
 
IT worked intially with same report server, Now it give out the above error.
 
Can you help me on it.
GeneralRe: system.web.webexceptionmemberMark Brandon21 May '07 - 3:52 
Any more detail on *where* this error is occuring? Can you manually connect to the service?
 

GeneralRe: system.web.webexceptionmembertaersious3 Sep '09 - 10:23 
I also get this System.Net.WebException. I believe it may be permissions to the Destination Server not being set. I can navigate to the source server path (minus the reportservice.asmx) but I cannot navigate to the destinatin server path (minus the asmx). Not sure what I have to configure on the Destination Server to allow this migration. If this works, I am thrilled. If not, Confused | :confused:
GeneralRe: system.web.webexceptionmemberMark Brandon3 Sep '09 - 10:38 
The code just calls the API to do all the work you could do by hand via the managment interface (http://{yourserver}/reports).
 
If you don't have the permissions to query & publish reports, data sources and shared schedules, it isn't going to work. I wrote this to support our custom code migration tool, and the infrastructure ppl who do migrations have complete (local admin) rights the the involved boxs. It may be that I am querying something that you have rights to on your source box but not the destination - if you can run in a debugger, and pinpoint what it is doing, maybe that will help you figure out what rights you need.
 
It's a good first step to see if you can navigate the service "file system" (http://{yourserver}/reportserver); then try manually publishing and setting up a report via the management interface.
 
Also, this was written against the 2000 server release - we are upgrading to 2008 soon, so I will be testing and fixing if needed, but for now I can't tell you if there may be an API change that may be causing this problem.
 
-mb
GeneralRe: system.web.webexceptionmembertaersious3 Sep '09 - 10:58 
Thanks for the reply. I appreciate you providing this tool, and understand how you use it. I have a need to migrate from 2005 to 2005. To make it more interesting, the destinatin 2005 is a Vista Laptop! (uhg)
If you post an update to this tool, I'd be very interested. Much thanks,
DC
GeneralCrystal MigrationmemberSKRIMPS6 Mar '07 - 8:01 
I've searched off and on for about a month now and not finding anything useful, has anyone ever developed or is there available a tool that can migrate a crystal report file to an SRS file? I have recently taken over the development team and we have crystal reports scattered all over this company and I'm moving everything to SQL Reports. one of the main issues I'm having is everything is still in Crystal 8.5. At last count, I have a list of about 130 reports for conversion and just wondering if I'm wasting my time searching and should just bite the bullet and bring in a short term contractor for this. Any feedback would be wonderful, this is the closest thing I've found to someone who's gone through this before.
THANKS!!
GeneralRe: Crystal MigrationmemberMark Brandon6 Mar '07 - 8:39 
I'd love to see a converter you could buy... we have over 300 active reports, and way over 1000 8.0 Crystal .rpt files floating around.
 
I'm afraid, however, that I've not seen any such beast. There are some companies that will either do the conversion, or use some sort of in-house tool to auto-generate a starting point, but in either case a person has to do the work.
 
We've decided to just do new reports using SRS, and convert our most used reports as we have time to SRS - so far that has worked, although as we get into some of the stuff with fiddlier layout / placement of static objects (specialized invoices and the like), I expect that it won't be as simple.
 
I looked, but don't seem to have my list of bookmarks anymore, since we decided to stay in-house.
 
-mb
GeneralChanging database type at run timememberAlexEvans28 Nov '06 - 16:16 
Thanks for sharing
 
I have lots of Crystal reports that have been designed to run against an MS-SQL Server. Now I want to run these same reports against a MYSQL Server…
 
Is there a way to change this at run time (through an API or any other way) with the need to maintain TWO versions of each report.
 
Hope someone can help me out here…
 
Cheers
Alex

GeneralSecurity Settingsmembercolby.jones23 Mar '06 - 4:06 
I am getting several "Method not allowed" errors when attempting to load the tree. Any ideas on what I need to enable? Thanks for the help...
 
Colby Jones
GeneralRe: Security SettingsmemberMark Brandon23 Mar '06 - 4:09 
I don't remember any issues like that... Can you run the compiled sample? What if you build the sample?
 
What version of .NET are you using? I haven't tested / updated for 2.0 yet.
 

GeneralRe: Security Settingsmembercolby.jones23 Mar '06 - 4:25 
Thanks for the quick response.
 
I have tried both versions as administrator. We are using Reporting Services 2005 on Windows 2003 Server. Both .Net 1.1 and 2.0 are loaded locally and on the server.
 
It is failing on "items = rs.ListChildren(path, False)" in the Private Function getTreeBranch(ByVal rs As ReportingService, ByVal path As String, ByVal Parent As RSItemNode, ByVal tn As RSItemNode) As RSItemNode.
 

AnswerRe: Security SettingsmemberMark Brandon23 Mar '06 - 4:46 
Well, the other thing we haven't upgraded to is SQL 2005 - this is written against Reporting Services for SQL 2000.
 
I don't know if their has been some change in the implementation of ListChildren, but looking at the method definition from 2000 (See below) the only permissions needed are "Read Properties" (to the folder path) - (that permission would be in Reporting Services).
 
In 2000, the "Browser" Role has this right for folders / reports / resources, and the "Content Manager" has the right for those as well as data Sources.
 
Note that being in the "System Administrator" role *DOES NOT* give you membership in those roles - you can have access to administer the RS system, but not actually have access to any content.
 
You can browse to http:\\{reportserver}\Reports and see items with the same login as is running the application, correct?
 

_______________Extract of BOL for RS 2000___________________
 
Public ListChildren( _
ByVal Item As String, _
ByVal Recursive As Boolean _
) As [Namespace].CatalogItem()
Member of [Namespace].ReportingService
 
Parameters
 
Item
The full path name of the parent folder.
 
Recursive
A Boolean expression that indicates whether to return the entire tree of child items below the specified item. The default value is false.
 
Return Value
An array of CatalogItem[] objects. If no children exist, this method returns an empty CatalogItem object.
 
Permissions
 
Operation Description
Read Properties Required to read meta data properties that are associated with an item.
 

Remarks
The ListChildren method returns only child items that the user has permission to view. The items that are returned may not represent a complete list of child items of the specified parent item.
 
If the ListChildren method is called on the root of the report server database with My Reports enabled, the method returns an array of CatalogItem[] objects containing properties for the folder My Reports. If the user is anonymous and My Reports is enabled, the properties for My Reports are not returned when ListChildren is called on the root.
 
The ListChildren method can return the VirtualPath property of items in the report server database that support virtual paths. The virtual path is the path under which a user expects to see the item. For example, a report called report1, which is located in the user's personal My Reports folder, has a virtual path equal to /My Reports. The actual path of the item is /Users/Username/My Reports.
 
The majority of the properties this method returns are read-only. For more information about item properties in Reporting Services, see Report Server Item Properties.
 

GeneralRe: Security Settingsmembercolby.jones23 Mar '06 - 9:50 
I got it working. Looks like either the .Net framework or Reporting Services is corrupt on the test system I chose to use. I pointed to another report server and it worked like a champ. Thanks for the help... BTW, this app works fine with RS 2005.
GeneralExcellent MarkmemberMattias438728921 Oct '04 - 22:20 
An excellent piece of work you have done here. It saved me a couple of days work (and will save me even more) and though the application is just a test application it works good enough for my needs. It would have been nice to be able to just select the top node of the tree structure and then migrate the whole hierarchy, or at least “shift-select” reports but I can easily add that functionality my self I believe.
 
We have nearly 100 reports and a couple of test environments (development-, system- and acceptance test), an education environment and a production environment. The reports are scheduled in a lot of different ways and because Microsoft doesn’t provide an own tool for adding the reports in specific structures this has been a tedious job to do manual or by script.
 
Thanks a lot Mark and Code Project.

 
/Mattias
GeneralRe: Excellent MarkmemberMark Brandon25 Oct '04 - 3:04 
Thanks!
 
Did you work out how to do the selection you wanted? I know we have that capability in the actual migration app the object was intended for use in, so I could scavange the code easily enough if you need help.
 
If you are going to use this a lot, I would encourage you to either flesh out the error handling in the object tester, or write your own "shell" app that works for your enviornment using the helper object to do the work - I spent a good amount of time testing the object, and none at all on the test framework itself! Smile | :)
 
Did you extend it to handle subscriptions, or is the render scheduling all you needed?
 

GeneralRe: Excellent MarkmemberMattias438728925 Oct '04 - 3:54 
Hi!
 
I haven't have time to do dig into it yet because we are in the middle of a major release process, but if you want to send me that extra code I won’t complain at all Smile | :) .
 
At first I thought we had the need of copy subscriptions as well but it turned out we don’t want to use the subscription feature in the test, education and development environment anyway so we will just configure it in the production area.
 
I know the shell isn’t tested and have some flaws but as I said it cover our needs and if/when it doesn’t it’s easy enough to change it.
 
Thanks a lot once again.
 
/Mattias

GeneralRe: Excellent MarkmemberMark Brandon29 Oct '04 - 15:33 
I'll see what I can find... Smile | :)
 
That's actually the reason I didn't do the subscriptions & security... we didn't want to move either from dev to production... although I figured I might add them eventually just to be complete.
GeneralRS deploymentmemberre_das20 Sep '04 - 10:34 
Interesting and maybe useful, but seems pointless to me...I still think you can't beat the deployment scripts (.rss) for a the primary reason that only the RS admin tools need to be installed to execute the deployments. The admins I have worked with much prefer a console app/command line tool they can script if necessary to handle their deployment needs. On the downside, the VS.NET ide doesn't really offer a lot of help with the rss files and you're tied to VB.NET.
 
Important point is that the RS Web service is fully capable of providing deployment, configuration, administration, and execution services for RS.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 10 Sep 2004
Article Copyright 2004 by Mark Brandon
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid