当前位置: 动力学知识库 > 问答 > 编程问答 >

vbscript - Can't access multiple records being returned by sql via ADODB.Recordset object

问题描述:

When I execut the sql direct it returns 4 records. when I execute the oraCommand.Execute the oraResults object shows only 1 record returned it should have a count of 4.

Hence I can get the value and name for the single record. Question is how do I get the other 3 records? I have tried set oraResults=oraResults.NextRecordSet() and I get error saying not supported!

Any help will appreciated.

This is the snippet of the code:

set oraCommand = CreateObject("ADODB.Command")

'set connection and sql statement

set oraCommand.ActiveConnection = oraConnection

oraCommand.CommandText =oraSQLStatement

oraCommand.CommandType = 1 ' commandText

oraCommand.Prepared = True

set oraResults = CreateObject("ADODB.Recordset")

'run the sql

set oraResults = oraCommand.Execute

oraResults.Fields(0).Name - Name from first record is returned

oraResults.Fields(0)>Value - Value from first record is returned

网友答案:

Try something like this: loop through the oraResults recordset and read the records:

Do until oraResults.EOF
   Response.Write oraResults("firstFieldName")
   Response.Write oraResults("secondFieldName")
   oraResults.MoveNext
Loop

Here's a link that might help.

分享给朋友:
您可能感兴趣的文章:
随机阅读: