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:
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 On Error GoTo errHandler '****snipped out loads of code - here's the important bit*** 'Send query to server Set cmdSearch = CreateObject("ADODB.Command") With cmdSearch .ActiveConnection = GDRConnect .CommandType = adCmdText .CommandText = "{? = CALL GDA_APP.SUBMIT_SEARCH(?,?,?,?,?,?,?)}" .Parameters.Append .CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue) '****etc. setting up all the other params**** .Properties("SPPrmsLOB").Value = True If Async Then .Execute , , adExecuteNoRecords + adAsyncExecute Set AsyncCommandObject = cmdSearch SubmitSearch = True Else .Execute , , adExecuteNoRecords SubmitSearch = (.Parameters("RETURN_VALUE").Value = 0) End If End With 'Notify MTS CtxSetComplete Exit Function errHandler: ErrorIn "User.SubmitSearch(GDRConnect,UserName,SearchString,UseMap)", Array(GDRConnect, Username, _ SearchString, UseMap), EA_NORERAISE HandleError End Function
2. ASP Code in submit search page
VB Code:
'Submit Query to GDA Engine set gdaUser = Server.CreateObject("GDA_Engine.User") 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 set Session.Contents("RunningQuery") = objQuery Response.Redirect "GDASubmitSearch.asp"
3. ASP Code in polling/cancel page
VB Code:
Sub action_cancelSearch() 'Cancel the query set objQuery = Session.Contents("RunningQuery") objQuery.Cancel Response.Redirect "GDASearch.asp" End Sub
The execution will wait on the "objQuery.Cancel" line until the stored procedure finishes (so it doesn't cancel).




Reply With Quote