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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

vb5-rdo

Dear Experts,

Can you please  tell me how to detect there is no records in database by using RDO method ?
thanks


SWP
0
SWP
Asked:
SWP
1 Solution
 
usermilesCommented:
rstObject.movefirst
   If rstObject.EOF = True Then    
      MsgBox "No Records were found"
   End If

If you use the rst.EOF command in the above example, this will set the resultset to the first record , and the If statement tests to see if you are at the end of the file.
0
 
VerolandCommented:
If you want to check a resultset it is easier if you use if RS.rowcount = 0.
usermiles example with give a error if there is no record in the table.
0
 
manish77Commented:
I agree with veroland. The best way is to check the count property
0
 
jharriCommented:
Depending on the datasource and the ODBC driver in use, rowcount can be expensive.  I suggest the following:

if rst.eof and rst.bof then
    Exit Sub
Else
    'Process the records
endif

No need here to use a move method (which is what could generate the error)

0
 
SWPAuthor Commented:
UserMiles:

   thanks for ur answer, but I prefered using the following:) since the I am using the SQL Server, there are no problems in using the rowCount method, but if I am using the Acces Driver, then
jharri's method is suggested.

 If rs.rowcount=0 then
    msgbox "no record found"
end if
 
but I heard jharri said that the rowcount is expensive, why do u think so ?



SWP
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now