top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How we can create folders in SQLReport server dynamically?

+1 vote
237 views
How we can create folders in SQLReport server dynamically?
posted Oct 3, 2014 by Amit Kumar Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

In SQLReporting we can create folders, datasource and deploy reports mannually by opening the report manager. Sometimes it becomes very cumbersome process to access the report manager and create folders, datasources, deploy reports manually if we have a lots of things to do at same time.
Imports System

Imports System.IO

Imports CreateReportFolderDemo.RSService

Imports System.Web.Services.Protocols

Imports System.Net

Public Class Form1

    Private Sub btnCreateFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateFolder.Click

        Dim rsMyReportService As New ReportingService()

        Dim arrCatlogItems As CatalogItem() = Nothing

        Dim scMySearchCondition As New SearchCondition()

        Dim strTargetFolder As String = String.Empty

        'Get the folder name

        strTargetFolder = Trim(txtFolderName.Text)

        'Set the report service path

        rsMyReportService.Url = "http://MyReportServer/ReportService.asmx"

        'Set the default credentials that has the right to access the webservice

        rsMyReportService.Credentials = System.Net.CredentialCache.DefaultCredentials

        If Not String.IsNullOrEmpty(strTargetFolder) Then

            'Set a search condition

            scMySearchCondition.Condition = ConditionEnum.Equals

            scMySearchCondition.ConditionSpecified = True

            scMySearchCondition.Name = "Name"

            scMySearchCondition.Value = strTargetFolder

            Dim ReportConditions(0) As SearchCondition

            ReportConditions(0) = scMySearchCondition

            Try

                'Check the item in the report server

       arrCatlogItems = rsMyReportService.FindItems("/", BooleanOperatorEnum.Or, ReportConditions)

                If CInt(arrCatlogItems.Length) = 0 Then

                    'Create a custom property for the folder.

                    Dim pNewProperty As New [Property]()

                    Dim pMyCustomProperty(0) As [Property]

                    pNewProperty.Name = "Description"

                    pNewProperty.Value = "This is the description about the folder"

                    pMyCustomProperty(0) = pNewProperty

                    'Create the folder in the report server

     rsMyReportService.CreateFolder(strTargetFolder, "/", pMyCustomProperty)

                    MsgBox("Folder created successfully")

                Else

                    MsgBox("Folder Exists in the server")

                End If

            Catch ex As SoapException

                MsgBox(ex.Message.ToString())

            Catch ex As Exception

                MsgBox(ex.Message.ToString())

            End Try

        Else

            MsgBox("Please specify folder name.")

        End If

    End Sub

End Class

Note: Report service need to be referenced in to the application to access the Web service methods.

answer Oct 5, 2014 by Kali Mishra
...