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 RetrieveChildFolders(IStore, ParentID , FolderNames, IDs)
'This function retrieves the names of child folders in a given folder.
'IStore - The InfoStore object required to interface with server.
'ParentID - The ID of the parent folder containing the children to be retrieved.
'FolderNames - A variant to hold the folder names (This variable must be empty).
'IDs - A variant to the hold the folder IDs (This variable must be empty).
'FolderNames - An array containing the names of the child folders.
'IDs - An array containing the IDs of the child folders.
'The arrays are empty if there are no folders.
'If an error occured the function returns FALSE, otherwise it returns TRUE.
'The query that will select all the child folders.
'Create a query that selects all the folders for a particular object.
'SI_PARENT_FOLDER is used to identify the parent folder.
'SI_PROGID = 'CrystalEnterprise.Folder' specifies that we only want folders back.
Query = "Select SI_NAME, SI_ID From CI_INFOOBJECTS Where " & _
"SI_PROGID = 'CrystalEnterprise.Folder' And SI_PARENT_FOLDER=" & CStr(ParentID)
Set Result = IStore.Query(Query)
'There was an error querying the server.
'Check that there are folders to view.
'Reallocate the array to make room for the folder names.
Redim FolderNames(Result.Count)
'Retrieve the folder IDs from the query result.
Function RetrieveParentID(IStore, ChildID, ParentID)
'This function retrieves the ID number of a particular folders
'IStore - The InfoStore object required to interface with server.
'ChildID - The ID of the child whose parent ID is to be retrieved.
'ParentID - Stores the ID of the child's parent.
'ParentID will be empty if there is no parent.
'If an error occured the function returns FALSE, otherwise it returns TRUE.
'The query that will select all the child folders.
'Create a query that selects the parent's ID for a folder.
Query = "Select SI_PARENTID From CI_INFOOBJECTS Where SI_ID = " & _
ChildID & " And SI_PROGID = 'CrystalEnterprise.Folder'"
Set Result = IStore.Query(Query)
'There was an error querying the server.
'Retrieve the ID from the query result.
ParentID = Result.Item(1).ParentID
'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"
'Otherwise display the folders and the "Up a Level" link.
Response.Write "<B>Folders</B><BR><BR>"
'Retrieve the child folders for the current folder.
Result = RetrieveChildFolders(IStore,CurrentFolderID,FolderNames,FolderIDs)
'Check to see if the function was successful.
'Retrieve the parent's ID for the current folder.
Result = RetrieveParentID(IStore,CurrentFolderID,ParentID)
'Check to see if the query was successful.
'If this is not the top level of folders display the "Up a Level" link.
If Not IsEmpty(ParentID) And (CurrentFolderID<>0) Then
Response.Write "<A HRef='home.csp
'If there are sub
If Not isEmpty(FolderNames) Then
For k = 1 to UBound(FolderNames)
Response.Write "• " & "<A HRef='home.csp
Server.HTMLEncode(FolderNames(k)) & "</A><BR>"
Response.Write "No Sub
Response.Write "There was an error trying to retrieve the parent folder."
Response.Write "There was an error trying to retrieve the sub
Crystal Decisions, Inc. http://www.crystaldecisions.com Support services: http://support.crystaldecisions.com |