Reports.csp

To download the CSP files from this tutorial, click TutorialSamples_vb.zip. For more information about using the samples, see Code examples.


<HTML>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=charset=UTF-8">

<BODY>

<!-- #include file=RetrieveIStore.csp -->

<%



Function RetrieveReports(ParentID ,IStore, Error)

'This returns an HTML table that is populated with the report name,

'report description, and the last time it was modified.

'

'Precondition:

'ParentID - The ID of the parent folder containing the reports to be retrieved.

'IStore - The InfoStore object required to interface with server.

'Error - A variable to hold the error if one occurs.


'

'Postcondition:

'Error - Contains the error number: 0 if successful.


'

'Notes:

'The function returns a string that is an HTML table.


    'The query that will select the reports.

    Dim Query  

    'The result of the query.

    Dim Result

    'A string to hold the HTML table.

    Dim HTMLTable

    HTMLTable=""

        

    'Create a query that selects all the reports, but doesn't select the instances.

    query = "Select SI_NAME, SI_ID, SI_DESCRIPTION, SI_UPDATE_TS From CI_INFOOBJECTS Where " & _

    "SI_PROGID='CrystalEnterprise.Report' And SI_INSTANCE=0 AND SI_PARENT_FOLDER=" & CStr(ParentID)

    

    

On Error Resume Next

    'Query the server.

    Set Result = IStore.Query(Query)

    If Err.Number <> 0 Then

        'There was an error querying the server.

        Error=Err.Number

        Exit Function

    End If


    

    If Result.Count > 0 Then


        'Set up the table header.

        HTMLTable="<TABLE Border=0 width = ""100%"">" & _

                              "<TR><TD><B>Name</B></TD>" & _

                              "<TD><B>Description</B></TD>" & _

                              "<TD><B>Last Modified</B></TD></TR>"

        

        Dim oReport

        For each oReport in Result

        'Add the report name and details to the table    

            HTMLTable=HTMLTable & _

            "<TR  valign=top><TD>" & _

            "<A HRef='ReportDescription.csp?ReportID=" & CStr(oReport.ID) & _

            "&FolderID=" & ParentID & "' Target='Main'>" & _

             Server.HTMLEncode(oReport.Title) & "</A></TD>" & _

            "<TD>" & Server.HTMLEncode(oReport.Description) & "</TD>" & _

            "<TD>" & oReport.Properties("SI_UPDATE_TS") & "</TD></TR>"

            

            Next

        HTMLTable=HTMLTable&"</TABLE>"

    End If

    

    RetrieveReports    = HTMLTable

    'Indicate success.

    Error=0

End Function


Dim Result

Dim ReportNames

Dim ReportIDs

Dim IStore

Dim CurrentFolderID

Dim Error


'Retrieve the CurrentFolderID from the file's parameter list.

CurrentFolderID = Request.QueryString("FolderID")



'Try to retrieve the InfoStore object.

If RetrieveIStore(IStore)=FALSE Then

    'If it failed redirect, the user to the logon page.

    Response.Redirect "LogonForm.csp"


Else

  Dim HTMLTable

  HTMLTable= RetrieveReports(CurrentFolderID, IStore,Error)

  If Error=0 Then

    Response.Write "<B>Report Listing</B><BR><BR>"

    If HTMLTable <> "" Then

        Response.Write HTMLTable

    Else

      Response.Write "No reports..."

      

    End If

Else

    Response.Write "There was an error trying to retrieve the reports."

End If


End If


%>

</BODY>

</HTML>




Crystal Decisions, Inc.
http://www.crystaldecisions.com
Support services:
http://support.crystaldecisions.com