Here's my scenario;
- I have a web application in classic ASP which uses some COM+ components written in VB6

- There is a "Search" action which can be VERY long and goes like this;
1. ASP page creates a GDA_Engine.User (COM+) object and calls the "SubmitSearch" function (see below)
2. This calls an Oracle stored procedure using an asynchronous execute and returns a reference to the ADODB.Command object (in one of the function parameters)
3. ASP page stores a reference to the long running ADODB.Command in the Session
4a. ASP page polls until the Command is complete and then goes to a search results page...
4b. ...OR user hits a "Cancel" link which gets the ADODB.Command from the Session and calls the .Cancel method


My problem is with the asynchronous cancel. The Cancel method NEVER works - the Command/stored procedure will continue to execute until it's finished. Plus, when the Cancel method is called, it blocks until the stored procedure has finished its work, so the ASP page takes ages to return. I've confirmed that the Command is stored/retrieved correctly from the Session (other methods/properties of the Command object can be used ok). Anyone got any ideas?

Here's the relevant code snippets;
1. VB SubmitSearch function in COM+ dll
VB Code:
  1. Public Function SubmitSearch(GDRConnect As String, Username As String, SearchString As String, Optional UseMap, Optional Clear, Optional UseSeeps As Boolean = False, Optional StartAge As String = "", Optional EndAge As String = "", Optional Async As Boolean = False, Optional AsyncCommandObject) As Boolean
  2. On Error GoTo errHandler
  3. '****snipped out loads of code - here's the important bit***
  4.        'Send query to server
  5.     Set cmdSearch = CreateObject("ADODB.Command")
  6.     With cmdSearch
  7.         .ActiveConnection = GDRConnect
  8.         .CommandType = adCmdText
  9.         .CommandText = "{? = CALL GDA_APP.SUBMIT_SEARCH(?,?,?,?,?,?,?)}"
  10.         .Parameters.Append .CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue)
  11.         '****etc. setting up all the other params****
  12.         .Properties("SPPrmsLOB").Value = True
  13.        If Async Then
  14.             .Execute , , adExecuteNoRecords + adAsyncExecute
  15.             Set AsyncCommandObject = cmdSearch
  16.             SubmitSearch = True
  17.         Else
  18.             .Execute , , adExecuteNoRecords
  19.             SubmitSearch = (.Parameters("RETURN_VALUE").Value = 0)
  20.         End If
  21.     End With
  22.  
  23.     'Notify MTS
  24.     CtxSetComplete
  25.  
  26.     Exit Function
  27. errHandler:
  28.     ErrorIn "User.SubmitSearch(GDRConnect,UserName,SearchString,UseMap)", Array(GDRConnect, Username, _
  29.             SearchString, UseMap), EA_NORERAISE
  30.     HandleError
  31. End Function

2. ASP Code in submit search page
VB Code:
  1. 'Submit Query to GDA Engine
  2. set gdaUser = Server.CreateObject("GDA_Engine.User")
  3. if gdaUser.SubmitSearch(CStr(Session.Contents("DB")), CStr(Session.Contents("Username")), CStr(Session.Contents("CurrentQuery")), Session.Contents("UseMap"),Session.Contents("ClearFirst"),Session.Contents("UseSeeps"),Session.Contents("StartAge"),Session.Contents("EndAge"),True,objQuery) then
  4.         set Session.Contents("RunningQuery") = objQuery
  5.         Response.Redirect "GDASubmitSearch.asp"

3. ASP Code in polling/cancel page
VB Code:
  1. Sub action_cancelSearch()
  2. 'Cancel the query
  3.     set objQuery = Session.Contents("RunningQuery")
  4.     objQuery.Cancel
  5.     Response.Redirect "GDASearch.asp"
  6. End Sub

The execution will wait on the "objQuery.Cancel" line until the stored procedure finishes (so it doesn't cancel).