codice:
function countChilds(theParentID)
theQuery = "SELECT COUNT(idProdotto) FROM prodotti WHERE idCategoria = " & theParentID
set theRecordset = conn.execute(theQuery)
countChilds = theRecordset(0)
theRecordset.close
set theRecordset = nothing
end function
set conn = server.createObject("ADODB.Connection")
conn.open connString
sql = "SELECT categoria, idCategoria FROM categorie"
set rs = conn.execute(sql)
if not rs.eof then
do until rs.eof
response.write rs("categoria") & " " & countChilds(rs("idCategoria")) & "
"
rs.moveNext
loop
end if
rs.,close
set rs = nothing
conn.close
set conn = nothing