Hello,
I am having trouble disconnecting from the APS with my VB application. Specifically, here is what my VB app does:
1) Updates the pick list of a report by obtaining a recordset through an ODBC database query (it can either be a table/field combination or a custom SELECT statement). The VB app then updates the report file directly via the CRAXDRT object and overwrites the old .rpt.
2) The VB app then connects to the APS via CrystalEnterpriseLib and CrystalInfoStoreLib libraries, searches for the report in the file repository, and overwrites that file with the updated .rpt.
3) The VB app will be scheduled nightly to run and update the pick lists of the reports and then, subsequently, the APS.
4) Users will then have a "dynamic" pick list in their reports.
My problem is the VB application is not disconnecting properly with the APS so that when it finishes processing, the task remains in Task Manager. I tried setting the IStore object to nothing but this doesn't do anything. I tried to use the DoAction method (to try to execute the ActionID -30000 which is supposed to disconnect from the APS) of the InfoObject object but this does nothing either.
Please refer to the following code:
-----Begin Code-----
Public Function UpdateAPS(szAPSReport As String, szNewReport As String, szUser As String, szPass As String, szServer As String, szSecType As String) As Integer
Dim oSessionManager As New SessionMgr
Dim Sess As EnterpriseSession
Dim oIStore As New InfoStore
Dim cReports As InfoObjects
Dim oReportToUpdate As InfoObject
Dim cFileInfo As Files
Dim oFileToUpdate As File
Dim oFileOptions As New FileOpOptionalInfo
Dim szName As String
On Error GoTo UpdateAPSErrHandler
Set oSessionManager = CreateObject("CrystalEnterprise.SessionMgr"
Set Sess = oSessionManager.Logon(szUser, szPass, szServer, szSecType)
Set oIStore = Sess.Service("", "InfoStore"
Set cReports = oIStore.Query("SELECT SI_FILES FROM CI_INFOOBJECTS WHERE SI_PROGID = 'CrystalEnterprise.Report' AND SI_NAME = '" & szAPSReport & "'"
If cReports.Count = 0 Then
Err.Description = "Report does not exist in the APS database."
GoTo UpdateAPSErrHandler
End If
Set oReportToUpdate = cReports.Item(1)
Set cFileInfo = oReportToUpdate.Files
Set oFileToUpdate = cFileInfo.Item(1)
szName = oFileToUpdate.Name
' MsgBox szName & " will be the file to be updated." & vbCrLf & "There are " & CStr(cFileInfo.Count) & " file(s) associated with this report."
oFileOptions.UseUniqueName = True
oFileToUpdate.Overwrite szNewReport, oFileOptions
oIStore.Commit cReports
' oReportToUpdate.DoAction 0, -30000, Null
Set oSessionManager = Nothing
Set Sess = Nothing
Set oIStore = Nothing
' Set oIStore = Sess.Service("", ""
Set cReports = Nothing
Set oReportToUpdate = Nothing
Set cFileInfo = Nothing
Set oFileToUpdate = Nothing
Set oFileOptions = Nothing
UpdateAPS = 0
Exit Function
UpdateAPSErrHandler:
ErrDesc = "Unable to update APS." & vbCrLf & "Error " & Err.Number & "- " & Err.Description
UpdateAPS = 1
End Function
-----End Code-----
How do you properly disconnect from the APS using VB?
Any help will be most appreciated.
Best,
rcs
I am having trouble disconnecting from the APS with my VB application. Specifically, here is what my VB app does:
1) Updates the pick list of a report by obtaining a recordset through an ODBC database query (it can either be a table/field combination or a custom SELECT statement). The VB app then updates the report file directly via the CRAXDRT object and overwrites the old .rpt.
2) The VB app then connects to the APS via CrystalEnterpriseLib and CrystalInfoStoreLib libraries, searches for the report in the file repository, and overwrites that file with the updated .rpt.
3) The VB app will be scheduled nightly to run and update the pick lists of the reports and then, subsequently, the APS.
4) Users will then have a "dynamic" pick list in their reports.
My problem is the VB application is not disconnecting properly with the APS so that when it finishes processing, the task remains in Task Manager. I tried setting the IStore object to nothing but this doesn't do anything. I tried to use the DoAction method (to try to execute the ActionID -30000 which is supposed to disconnect from the APS) of the InfoObject object but this does nothing either.
Please refer to the following code:
-----Begin Code-----
Public Function UpdateAPS(szAPSReport As String, szNewReport As String, szUser As String, szPass As String, szServer As String, szSecType As String) As Integer
Dim oSessionManager As New SessionMgr
Dim Sess As EnterpriseSession
Dim oIStore As New InfoStore
Dim cReports As InfoObjects
Dim oReportToUpdate As InfoObject
Dim cFileInfo As Files
Dim oFileToUpdate As File
Dim oFileOptions As New FileOpOptionalInfo
Dim szName As String
On Error GoTo UpdateAPSErrHandler
Set oSessionManager = CreateObject("CrystalEnterprise.SessionMgr"
Set Sess = oSessionManager.Logon(szUser, szPass, szServer, szSecType)
Set oIStore = Sess.Service("", "InfoStore"
Set cReports = oIStore.Query("SELECT SI_FILES FROM CI_INFOOBJECTS WHERE SI_PROGID = 'CrystalEnterprise.Report' AND SI_NAME = '" & szAPSReport & "'"
If cReports.Count = 0 Then
Err.Description = "Report does not exist in the APS database."
GoTo UpdateAPSErrHandler
End If
Set oReportToUpdate = cReports.Item(1)
Set cFileInfo = oReportToUpdate.Files
Set oFileToUpdate = cFileInfo.Item(1)
szName = oFileToUpdate.Name
' MsgBox szName & " will be the file to be updated." & vbCrLf & "There are " & CStr(cFileInfo.Count) & " file(s) associated with this report."
oFileOptions.UseUniqueName = True
oFileToUpdate.Overwrite szNewReport, oFileOptions
oIStore.Commit cReports
' oReportToUpdate.DoAction 0, -30000, Null
Set oSessionManager = Nothing
Set Sess = Nothing
Set oIStore = Nothing
' Set oIStore = Sess.Service("", ""
Set cReports = Nothing
Set oReportToUpdate = Nothing
Set cFileInfo = Nothing
Set oFileToUpdate = Nothing
Set oFileOptions = Nothing
UpdateAPS = 0
Exit Function
UpdateAPSErrHandler:
ErrDesc = "Unable to update APS." & vbCrLf & "Error " & Err.Number & "- " & Err.Description
UpdateAPS = 1
End Function
-----End Code-----
How do you properly disconnect from the APS using VB?
Any help will be most appreciated.
Best,
rcs