Using ADO to access the db:
- execute a simple
SELECT count(0) FROM myTable
query.
- access the resultset (if not empty) and read the returned value.
Not tested code:
Dim conn, rs, recordsCount
recordsCount = -1
'initialize the connection
set conn = ...
'run the query and retrieve the results
set rs = conn.execute("SELECT count(0) as cnt FROM myTable")
if not rs.EOF then
recordsCount = cint(rs("cnt"))
end if
'cleanup
rs.close
conn.close
set rs = nothing
set conn = nothing
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…