Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Unable to loop through a ResultSet (Classic ASP, ADO)

$
0
0

All,

I have inherited a legacy web site and have encountered a problem that I can't get figure out:

The program structure is as follows:

 1. Execute a SQL Server Stored proc and create XML from the result set 

 2. If a condition is met, exceute a second stored proc and hydrate the XML from step one with some more tags

 3. return the XML is the response

Step 1 happens without problems, but when the condition is met the execution halts as soon as I try to do anything with the Result Set. For instance setRS.ActiveConnection = nothing or do until CustodianRS.EOF both halt execution. and I end up with an empty Response.

Here is the offending code:

if len(trim(strTradingArea)) = 4 then
dim CustodianCN
dim CustodianCMD
dim CustodianRS
dim node

set CustodianCN = server.CreateObject("ADODB.Connection")
CustodianCN.CursorLocation = adUseClient
CustodianCN.Open Application("PANORAMA_SACDETAILS")

set CustodianCMD = server.CreateObject("ADODB.Command")
with CustodianCMD
set .ActiveConnection = CustodianCN
.CommandType = adCmdStoredProc
.CommandTimeout = 300
.CommandText = "p_SACGetAccountCustodiansByTradingArea"
.Parameters("@TradingArea").Value = strTradingArea
set CustodianRS = .Execute
end with
'set CustodianRS.ActiveConnection = nothing
CustodianRS.Sort = "Custodian"
do until CustodianRS.EOF
set node = responseXML.createElement("custodian")
node.setAttribute "id",trim(CustodianRS.Collect("Custodian") & "")
node.setAttribute "parent",trim(CustodianRS.Collect("Parent") & "")
responseXML.firstChild.appendChild(node)
CustodianRS.MoveNext
loop
end if

Does anyone have any suggestions? Any help would be much appreciated, I have already spent a considerable amount of time on this.

Thanks!


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>