Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Using Recordcount with getrows?

Posted on 2003-03-10
4
Medium Priority
?
229 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
  • 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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

571 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