Parsing a recordset from an Oracle DB in Word with VBA

R

Raphael Wohl

Hi there,

I have this odd problem that I can't make sense of.

I connect to an Oracle DB (ADODB) fine and make a query. I get a recordset with a result. So far so good.

Then I want to read the fields of the recordset into an array.

Do While Not ora_rs.EOF
For i = 0 To (ora_rs.Fields.Count - 1) <---will return 32 for ora_rs.Fields.Count

If ora_rs.Fields(i).Value = myVariable Then <---- will generate an error message: Item cannot be found in the collection corresponding to the requested name or ordinal
REM do somethin
End If
If Not IsNull(ora_rs.Fields(i).Value) Then
myArray(i) = ora_rs.Fields(i).Value
End If
Next i

ora_rs.MoveNext

myCounter = myCounter + 1

Loop

The fun part is that when I break the code on the line where it generates the error message and evaluate the same expression in the debug window....it will return the value of the field.

I don't get it...really don't get it.

If I were to address the 32 fields by their names, ie ora_rs.Fields("myField1").Value a.s.o., it would return the results as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top