you have to close the recordset before retrieving the output valueSet Rs = cmdTemp.Execute
if RowCount>0 thenWhile Not RS.EOFfor each Field in RS.Fields
Response.Write Field.Name & "=" & Field.Value & "<br>" & vbCRLF
Next
Response.Write "<br>"
RS.MoveNext
Wendend ifRS.Close
RowCount=cmdTemp("@RowCount")
Response.Write cmdTemp.Parameters("@RowCount").Value
if RowCount>0 thenWhile Not RS.EOFfor each Field in RS.Fields
Response.Write Field.Name & "=" & Field.Value & "<br>" & vbCRLF
Next
Response.Write "<br>"
RS.MoveNext
Wendend ifRS.Close
RowCount=cmdTemp("@RowCount")
Response.Write cmdTemp.Parameters("@RowCount").Value
While Not RS.EOFfor each Field in RS.Fields
Response.Write Field.Name & "=" & Field.Value & "<br>" & vbCRLF
Next
Response.Write "<br>"
RS.MoveNext
Wend
RS.Close
2. if you insist, you can change your stored procedure like this:select @RowCount=count(id) from linking where sitename like @key_string or jiji like @key_stringselect @RowCount as RowCount.....then inside your asp, you can try
....Set Rs = cmdTemp.Execute
RowCount = RS("RowCount")
set RS =RS.NextRecordset
if RowCount>0 then
While Not RS.EOF
for each Field in RS.Fields
Response.Write Field.Name & "=" & Field.Value & "<br>" & vbCRLF
Next
Response.Write "<br>"
RS.MoveNext
Wend
end if
RS.Close
GetString = Rs.Getrows()
Rs.Close
RowCount=cmdTemp("@RowCount")把记录集先保存个一个数组里,再进行处理,呵呵。不过还是要谢谢你,希望继续以上的问题,怎么以你的理路做?不一定采用,但多学学别人的思路是好的。还有你能不能解决在7.0里以上的存储过程出错,不能用"*"乘号运算符?
@Key nvarchar(200) ,
@CurrentPage int,
@PageCount int,
@RowCount int OUTPUT
as
set nocount on
...
exec('drop table ##Tab' + @TimeName)
set oncount off
cmdTemp.Parameters.Append cmdTemp.CreateParameter("@Key",adVarChar,adParamInput,200,"Key")
cmdTemp.Parameters.Append cmdTemp.CreateParameter("@CurrentPage",adInteger,adParamInput,,iVal)
cmdTemp.Parameters.Append cmdTemp.CreateParameter("@PageCount",adInteger,adParamInput,,iVal)
cmdTemp.Parameters.Append cmdTemp.CreateParameter("@RowCount",adInteger,adParamOutput,,oVal)存储过程默认的第一个参数应该是return参数,你在这里没有定义他,所以你取不会返回纪录集,而你直接执行存储过程时,ado帮你做了处理,所以可以执行。