count number of sql query result

D

Dan

Is there a property that count the result of an SQL query.
I could find one that count the number of fields, but not the number of
results.

Is there another way to find out if an SQL return any result or no result
are returned.

Thanks

Dan
 
K

Keith74

Far as i know you have to run a loop for the number of records

i.e.

myrecordset.movefirst

do until myrecordset.eof = true
count = count + 1
myrecordset.movenext
loop

myrecordset.movefirst

The way i find out if i have an empty recordset is

if myrecordset.bof = true and myrecordset.eof = true then
your code here
end if


hth

keith
 
G

GysdeJongh

Dan said:
Is there a property that count the result of an SQL query.
I could find one that count the number of fields, but not the number of
results.

Is there another way to find out if an SQL return any result or no result
are returned.

Dim strSQL As String
Dim rcsCheck As New ADODB.Recordset
Dim intNumberOfRecords As Integer
'
strSQL = "Your Query"
rcsCheck.Open strSQL, "Provider=MSDASQL;DSN=YourDSN", adOpenStatic,
adLockOptimistic
intNumberOfRecords = rcsCheck.RecordCount

I tried a few things but this only seems to work for adOpenStatic,
adLockOptimistic
hth
Gys
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top