To download the CSP files from this tutorial, click TutorialSamples_vb.zip. For more information about using the samples, see Code examples.
<META HTTP
<!-- #include file=RetrieveIStore.csp -->
Function RetrieveReportInformation(ReportID, IStore, Error, Name, Description)
'This function retrieves the name and description of a particular report
'ReportID - The ID of the report currently being viewed.
'IStore - The InfoStore object required to interface with server.
'Error - A variable to hold the error if one occurs.
'Error - Contains the error number: 0 if successful.
'Name - The name of the report.
'Description - A description of the report.
'The query that will select the report details.
'A query that selects report details.
Query = "Select SI_NAME, SI_DESCRIPTION From CI_INFOOBJECTS Where " & _
Set Result = IStore.Query(Query)
'There was an error querying the server.
Name=Server.HTMLEncode(Result.Item(1).Title)
Description=Server.HTMLEncode(Result.Item(1).Description)
Function RetrieveReportInstances(ParentID ,IStore, Error, LogonToken)
'This returns an HTML table that is populated with the instance name,
'description and the last time it was modified.
'ParentID - The ID of the parent report containing the instances to be retrieved.
'IStore - The InfoStore object required to interface with server.
'Error - A variable to hold the error if one occurs.
'LogonToken - The user's logon token so that a link can be provided to view
'Error - Contains the error number: 0 if successful.
'The function returns a string that is an HTML table.
'The query that will select the instances.
'A string to hold the HTML table.
'Create a query that selects all the instance objects (SI_INSTANCE_OBJECT=1).
Query = "Select SI_NAME, SI_ID, SI_UPDATE_TS From CI_INFOOBJECTS Where " & _
"SI_INSTANCE_OBJECT = 1 AND SI_PARENTID=" & CStr(ParentID)
Set Result = IStore.Query(Query)
'There was an error querying the server.
HTMLTable="<table border=0 width = ""100%""><TR><TD><B>Name</B></TD>" & _
"<TD><B>Last Modified</B></TD></TR>"
For Each oDescription in Result
'Add the instance name and details to the table.
'Ensure that each name is a link to the viewer.
"<A Target='_blank' href='viewrpt.cwr
"&apsToken=" & Server.URLEncode(LogonToken) & "' >" & _
Server.HTMLEncode(oDescription.Title) & "</A></TD>" & _
"<TD>" & oDescription.Properties("SI_UPDATE_TS") & "</TD></TR>"
HTMLTable=HTMLTable&"</table>"
RetrieveReportInstances =HTMLTable
Dim CurrentReportID, CurrentFolderID
'Retrieve the CurrentFolderID from the file's parameter list.
CurrentReportID = Request.QueryString("ReportID")
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"
'This is the link back to the folder view listing all the reports.
Response.Write "<a href='reports.csp
"'><font size=
RetrieveReportInformation CurrentReportID, IStore, Error, Name, Description
Response.Write "<B><font size=+2>" & Name & "</font></b>"
'Draw the thumbnail in a table so that it has a border and scale
Response.Write "<P><TABLE Width='100%'><TR VAlign='Top'><TD>" & _
"<TABLE Border=1><TR><TD><CENTER><B>Preview</B></CENTER>" & _
"<IMG Width=159 Height=206 " & _
"SRC=""thumbnail.csp
'Write the report's description.
Response.Write "<TD>" & Description & "</TD></TR></TABLE>"
'Write out the instances associated with the report.
Response.Write "<BR><B><FONT Size=+2>Instances</FONT></B>"
'Retrieve the logon token so that the instances can be viewed in the report viewer.
LogonToken = Request.Cookies("LogonToken")
Instances = RetrieveReportInstances( CurrentReportID,IStore,Error,LogonToken)
Response.Write "<BR>There are no instances of this report." & _
" Schedule the report to create an instance of it."
Response.Write "Error: I could not retrieve the instances of this report."
'Write the links that enable the user to view, rename or schedule a report.
Response.Write "<HR><CENTER><A Target=""_blank"" HRef=""viewrpt.cwr
CurrentReportID & "&APSToken="&LogonToken&"""> View Report</A> - "
Response.Write "<A HRef='ChangeReportNameForm.csp
"&ReportName=" & Server.URLEncode(name) & "&FolderID="& CurrentFolderID & _
Response.Write " - <A HRef='ScheduleForm.csp
"&" & "FolderID=" & CurrentFolderID &" '>Schedule Report</A></CENTER>"
Response.Write "There was an error trying to retrieve the report details."
Crystal Decisions, Inc. http://www.crystaldecisions.com Support services: http://support.crystaldecisions.com |