Dreamweaver İle ASP'de Rastgele Veri Çekme

-A A +A

Blog Kategori: 

Dreamweaver ile çalışıyorsanız ve ASP'de rastgele MS Access'ten veri çekmek istiyorsanız aşağıdaki kodları kullanabilirsiniz...

 <%
' Moving to random record - Steven Jones' Extension
If Not(Recordset1.bof and Recordset1.eof) Then
  ' reset the cursor to the beginning
  If (Recordset1.CursorType > 0) Then
    Recordset1.MoveFirst
  Else
    Recordset1.Requery
  End If
 
  Recordset1_totalrn = -1
  Recordset1_totalrn = Recordset1.RecordCount ' ony works on some recordsets, but much faster
  If (Recordset1_totalrn = -1) Then ' and if it didn't work, we still have to count the records.

    ' count the total records by iterating through the recordset
    Recordset1_totalrn=0
    While (Not Recordset1.EOF)
      Recordset1_totalrn = Recordset1_totalrn + 1
      Recordset1.MoveNext
    Wend

    ' reset the cursor to the beginning
    If (Recordset1.CursorType > 0) Then
      Recordset1.MoveFirst
    Else
      Recordset1.Requery
    End If
    
  End If

' now do final adjustments, and move to the random record  
Recordset1_totalrn = Recordset1_totalrn - 1
If Recordset1_totalrn > 0 Then
Randomize
Recordset1.Move Int((Recordset1_totalrn + 1) * Rnd)
End If
End If
' all done; you should always check for an empty recordset before displaying data
%>

Sosyal Medyada Bizi Takip Edin

Günlükler

Zircon - This is a contributing Drupal Theme
Design by WeebPal.