?
Solved

Using Recordcount with getrows?

Posted on 2003-03-10
4
Medium Priority
?
228 Views
Last Modified: 2013-12-25
I've been using getrows, but I just came accross a problem and that problem is if there are no records I get an error.

So is there a way to use recordcount or eof to check if there are records returned before the getrows is even executed and if not return an empty array.

MY CODE:

Dim cnnGetRows As ADODB.Connection
Dim rstGetRows As ADODB.Recordset
Set cnnGetRows = New ADODB.Connection
rstGetRows.Open DBSTRING
Set rstGetRows = cnnGetRows.Execute("SELECT * FROM bookofsaleitems")
arrDBData = rstGetRows.GetRows(, , Array("Bookofsale", "category", "description", "endingdate", "endingtime", "ID", "itemname", "ourcommission", "photos", "price", "showonline", "soldonline", "startingdate", "startingtime", "taxable"))
rstGetRows.Close
Set rstGetRows = Nothing
cnnGetRows.Close
Set cnnGetRows = Nothing

And I know that I can just leave the getrows parameters null, I just wanted my information returned in a certain order.

0
Comment
Question by:hansamryan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Author Comment

by:hansamryan
ID: 8106175
sorry:
Line 4 shoudl be:
cnnGetRows.Open DBSTRING
0
 
LVL 34

Accepted Solution

by:
arbert earned 1000 total points
ID: 8106199
Dim cnnGetRows As ADODB.Connection
Dim rstGetRows As ADODB.Recordset
Set cnnGetRows = New ADODB.Connection
rstGetRows.Open DBSTRING
Set rstGetRows = cnnGetRows.Execute("SELECT * FROM bookofsaleitems")

if not rsGetRows.eof then      'check for rows
   arrDBData = rstGetRows.GetRows(, , Array("Bookofsale", "category", "description", "endingdate", "endingtime", "ID", "itemname", "ourcommission", "photos", "price", "showonline", "soldonline", "startingdate", "startingtime", "taxable"))
end if
   
rstGetRows.Close
Set rstGetRows = Nothing
cnnGetRows.Close
Set cnnGetRows = Nothing

0
 

Author Comment

by:hansamryan
ID: 8106292
thanks for the quick help, I have to get the software on a cd tonight!!
0
 

Author Comment

by:hansamryan
ID: 8106294
thanks for the quick help, I have to get the software on a cd tonight!!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question