Thumbnail.csp

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


<%



Function GetThumbnail (ID, IStr)

'This function will print the thumbnail

'of a particular report on the page.  It will remove

'any other text on the page.

'

'Precondition:

'ID - The ID of the report whose thumbnail is to be

'        retrieved.

'IStr - The InfoStore object that allows us to query.

'

'Note:

'The function returns TRUE if successful and FALSE otherwise.

On Error Resume Next

    'The query that will select the reports.

    Dim Query


    'The result of the query.    

    Dim Res    


    'The report object.

    Dim Obj    


    'The report interface.

    Dim RI    


    'The thumbnail.

    Dim TN    


    'A query that selects the report.

    Query = "Select Top 1* From CI_INFOOBJECTS Where SI_ID = " & ID

        

    Set Res = IStr.Query(Query)

    If Err.Number <> 0 Then

        'There was an error querying the server.

        GetThumbnail = FALSE

    End If

    

    'Check if there really is a report, just in case something

    'went wrong.

    If Res.Count > 0 Then

        Set Obj = Res.Item(1)

        If Err.Number <> 0 Then

             GetThumbnail = FALSE

        End If

    Else

        GetThumbnail = FALSE

    End If

    

    'Use the report plugin interface.

    Set RI = Obj.PluginInterface

    If Err.Number <> 0 Then

        GetThumbnail = FALSE

    End If


    If (RI.EnableThumbnail) then

        'Retrieve the thumbnail picture.

        TN = Obj.Picture(4)

        If (Err.Number = 0) then

            Response.ContentType = "image/jpeg"

            Response.BinaryWrite TN

        Else

            Response.Redirect "images/rpt_tn.gif"

        End If

    Else

        Response.Redirect "images/rpt_tn.gif"

    End If


End Function


'The InfoStore object.

Dim i


If RetrieveIStore (i) then

    Dim ID

    ID = Request.QueryString("ReportID")

    If Not GetThumbnail (ID,i) then

        Response.Write "There was an error retrieving the thumbnail."

    End If

Else

    'InfoStore couldn't be retrieved so go back to the logon page.

    Response.Redirect "LogonForm.csp"

End If


%>

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





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