Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default count number of sql query result

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default count number of sql query result


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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default count number of sql query result

"Dan" wrote in message
...
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
count number of repeats in a column highlight result bobular Excel Discussion (Misc queries) 1 January 11th 12 02:15 AM
Count result of sql query Dan Excel Discussion (Misc queries) 0 June 25th 07 04:50 PM
Replace ^ in web query result Don Guillett Excel Worksheet Functions 0 April 26th 06 03:42 PM
Replace ^ in web query result Don Guillett Excel Programming 0 April 26th 06 03:05 PM
Importing result from Access query to Excel but the result only c. Edwin Excel Discussion (Misc queries) 0 March 16th 06 01:36 AM


All times are GMT +1. The time now is 12:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"