Counting records

this code snippet will count the records in a database

<!-- #include file = "adovbs.inc"-->
<%
'variables for our objects
Dim objRS , objConn
'create instances of our objects
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
objConn.Open "DBQ=" & Server.MapPath("sampledb.mdb")& ";Driver={Microsoft Access Driver (*.mdb)}"
objRS.Open "tblsample" , objConn , adOpenStatic , adLockReadOnly , adCmdTable
'find available records and store them in a variable
AvailableRecords = objRS.RecordCount
'display available records
Response.Write "There are " & AvailableRecords & " available records in the table "
'tidy up by closing and deleting objects
objRS.Close
Set objRS = Nothing
Set objConn = Nothing
%>

 

Sponsors