Determining the size of a recordset

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2005
Posts: 192
Reputation: stupidenator is an unknown quantity at this point 
Solved Threads: 4
stupidenator's Avatar
stupidenator stupidenator is offline Offline
Junior Poster

Determining the size of a recordset

 
0
  #1
Sep 9th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 530
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 91
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: Determining the size of a recordset

 
0
  #2
Sep 10th, 2008
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
Selva
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 192
Reputation: stupidenator is an unknown quantity at this point 
Solved Threads: 4
stupidenator's Avatar
stupidenator stupidenator is offline Offline
Junior Poster

Re: Determining the size of a recordset

 
0
  #3
Sep 10th, 2008
Thanks for your help! I will give that a try
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 1654 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC