Da una tabella devo filtrare dei dati e poi ne devo estrarre uno random.
Il problema è che ogni tanto mi da EOF
Malgrado che abbia sottratto uno al totale il difetto mi rimane.
Dove sbaglio?
Vi riporto il listato
-----------------------------------------------------------
Dim oConn
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/mdb/MyDB.mdb"))
sSQL1 = "SELECT COUNT(*) AS tot_rec From MyTable where tipo_ovg='o'"
Set oConta = Server.CreateObject ("ADODB.Recordset")
oConta.Open sSQL1,oConn
TotBanner = oConta("tot_rec") - 1
oConta.Close
Set oConta = Nothing
sSQL = "SELECT link From MyTable where tipo_ovg='o'"
Set oMyValue = Server.CreateObject ("ADODB.Recordset")
oMyValue.Open sSQL,oConn,3,3
oMyValue.MoveFirst
Randomize
ValueCasuale = (cint(rnd() * TotValue)-1)
oMyValue.Move ValueCasuale
Stringa=oMyValue("link")
oMyValue.Close
Set oMyValue = Nothing
oConn.Close
Set oConn = Nothing
response.write (Stringa)
--------------------------------------------------------------

Rispondi quotando