943,607 Members | Top Members by Rank

Ad:
Sep 9th, 2008
0

Determining the size of a recordset

Expand Post »
Hello Everyone,

I am having some trouble with a VBA application I am writing for work. I am using ADODB to connect to an Oracle database and return and I want to return a 2-D array from my function. The problem I am having seems to be determining how big the recordset is so that I can ReDim my 2-D array to fit the results. Any help would be greatly appreciated. I have included the function below.

Thanks,
Nick

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Public Function QueryArray(QueryString As String) As String()
  2. Dim RowCount As Integer
  3. Dim ResultArray() As String
  4. Dim i As Integer
  5. RowCount = 0
  6. rsOra.Open QueryString, cnOra, adOpenForwardOnly
  7. ReDim ResultArray(0 To 100, 0 To 100) ' THIS IS WHERE I AM HAVING THE PROBLEM
  8. While Not rsOra.EOF
  9. For i = 0 To rsOra.Fields.Count - 1
  10. If IsNull(rsOra.Fields(i)) Then
  11. ResultArray(RowCount, i) = ""
  12. Else
  13. ResultArray(RowCount, i) = rsOra.Fields(i)
  14. End If
  15. Next
  16. RowCount = RowCount + 1
  17. rsOra.MoveNext
  18. Wend
  19. If IsArrayEmpty(ResultArray) Then
  20. Exit Function
  21. Else
  22. QueryArray = ResultArray
  23. End If
  24. End Function
Similar Threads
Reputation Points: 18
Solved Threads: 4
Junior Poster
stupidenator is offline Offline
192 posts
since Mar 2005
Sep 10th, 2008
0

Re: Determining the size of a recordset

Do you want to find no of records? If yes Recordset.RecordCount will help you to find no of records

Also try RecordSet.GetRows() method which returns array of records
Reputation Points: 44
Solved Threads: 101
Posting Pro
selvaganapathy is offline Offline
547 posts
since Feb 2008
Sep 10th, 2008
0

Re: Determining the size of a recordset

Thanks for your help! I will give that a try
Reputation Points: 18
Solved Threads: 4
Junior Poster
stupidenator is offline Offline
192 posts
since Mar 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Executing Query with criteria at run time
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Guys please help me





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC