stored procedure - doesn't support eof issue
I am calling a stored procedure and passing xml data and it is sending back the following error:
Object doesn't support this property or method: 'eof
Line erroring on: If Not rsResults.eof Then
Any thoughts on what I am doing wrong?
Code:
Code:
'Loop through list and put in xml string
arEmails = Split(CandidateList, ",")
sXml = ""
For Each sEmail in arEmails
sXml = sXml & "<candidate email=""" & sEmail & """ />"
Next
If Len(sXml) > 0 Then
sXml = "<candidates>" & sXml & "</candidates>"
' Selected constants from adovbs.inc
Const adCmdStoredProc = 4
Const adInteger = 3
Const adCurrency = 6
Const adExecuteNoRecords = 128
Const adVarChar = 200
Const adParamUnknown = 0 'Direction is unknown
Const adParamInput = 1 'Input parameter
Const adParamOutput = 2 'Output parameter
Const adParamInputOutput = 3 'Both input and output parameter
Const adParamReturnValue = 4 'Return value
Dim lngAdded, sResult
lngAdded = 0
sResult = ""
Set adoCmd = Server.CreateObject("ADODB.Command")
Set adoCmd.ActiveConnection = conntemp
Dim rsResults
Set rsResults = Server.CreateObject("ADODB.Recordset")
Dim param
'Set properties of the command
With adoCmd
.CommandText = "sp_XmlCandidatesByEmail"
.CommandType = adCmdStoredProc
Set param = .CreateParameter("@xmlCandidates", adVarchar, adParamInput, 8000)
.Parameters.Append param
.Parameters.Refresh
param.Value = sXml
'Run the stored procedure
rsResults = .Execute
'Response.Write(rsResults)
If Not rsResults.eof Then
Do While rsResults.eof = false
Response.Write(rsResults.Fields("Candidate_ID").Value)
rsResults.MoveNext
Loop
End If
rsResults.Close
Set rsResults = Nothing
End With
'Reset server command object
Set adoCmd = Nothing
End If
Stored procedure
Code:
ALTER PROCEDURE [dbo].[sp_XmlCandidatesByEmail]
-- Add the parameters for the stored procedure here
@xmlCandidates xml
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SET ARITHABORT ON
-- Create a table variable to store my items.
DECLARE @tblCandidates TABLE(email varchar(500))
-- Shred data carried in the XML and populate the table variable with it.
INSERT INTO @tblCandidates
SELECT
e.value('@email', 'varchar(500)')
FROM
@xmlCandidates.nodes('//candidate') tblCandidates(e)
select Candidate_id, Candidate_Email, Candidate_ActiveFlag
from candidate c
JOIN @tblCandidates t ON t.email = c.candidate_email
END
Re: stored procedure - doesn't support eof issue
I expect that the previous line (rsResults = .Execute) is the problem, because you have missed the SET keyword.
Note that there is no need for the earlier Set rsResults line, or the If/End If that is giving an error (the Do/Loop inside it does exactly the same check).