开发者

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 rec开发者_开发问答ords? 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜