Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    query su 2 tab + random records

    Non capisco come mai se faccio questa select mi da -1 come recordcount. Le due tabelle contengono 2 Artisti e 3 foto x ciascun artista.

    SELECT Tabfoto.Idfoto, Tabfoto.Idartista, Tabfoto.Titoloita, Tabfoto.Fotopiccola, Tabartisti.Idartista, Tabartisti.Nome, Tabartisti.Cognome FROM Tabfoto, Tabartisti WHERE Tabfoto.Idartista LIKE Tabartisti.Idartista

    Il valore recordcount mi serve poi in uno script di questo tipo:
    <%

    if not Rs_foto.EOF then
    N = 4 'numero di record casuali da visualizzare
    Randomize
    max = Rs_foto.RecordCount - 1
    redim arr(max)
    'popolo l'array da 0 al numero di record
    for i=0 to max
    arr(i)=i
    next
    'mischio i numeri in modo casuale
    for i=0 to max
    casuale = Int((max)*Rnd)
    temp = arr(i)
    arr(i) = arr(casuale)
    arr(casuale) = temp
    next


    end if
    %>

    che mi da questo errore (immagino per colpa del valore del recordcount):

    Microsoft VBScript runtime error '800a0007'

    Out of memory

    /index.asp, line 233

    http://www.diemmedi.com
    --------------
    "La citazione è l'anticamera dell'ignoranza" (André La Vallette)

  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 2003
    Messaggi
    254
    che cursore usi? Per il recordcout ti serve adopenkeyset

  3. #3
    Ciao, grazie per la risposta... Questa è la query:

    <%
    Dim Rs_foto
    Dim Rs_foto_numRows

    Set Rs_foto = Server.CreateObject("ADODB.Recordset")
    Rs_foto.ActiveConnection = conn_artisti
    if Session ("lang") = "ita" then

    Rs_foto.Source = "SELECT Tabfoto.Idfoto, Tabfoto.Idartista, Tabfoto.Titoloita, Tabfoto.Fotopiccola, Tabartisti.Idartista, Tabartisti.Nome, Tabartisti.Cognome FROM Tabfoto, Tabartisti WHERE Tabfoto.Idartista LIKE Tabartisti.Idartista "
    else
    Rs_foto.Source = "SELECT Tabfoto.Idfoto, Tabfoto.Idartista, Tabfoto.Titoloeng, Tabfoto.Fotopiccola, Tabartisti.Idartista, Tabartisti.Nome, Tabartisti.Cognome FROM Tabfoto, Tabartisti WHERE Tabfoto.Idartista LIKE Tabartisti.Idartista "
    end if
    Rs_foto.CursorType = 0
    Rs_foto.CursorLocation = 2
    Rs_foto.LockType = 1
    Rs_foto.Open()

    %>
    http://www.diemmedi.com
    --------------
    "La citazione è l'anticamera dell'ignoranza" (André La Vallette)

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2003
    Messaggi
    254
    sostituisci
    Rs_foto.CursorType = 0
    con
    codice:
    Rs_foto.CursorType = 1

  5. #5
    Ora funzia: uso Dreamweaver ed ho aperto il RS dal pannello e trascinato la voce Records Totali.
    Guardo cosa ha modificato.
    http://www.diemmedi.com
    --------------
    "La citazione è l'anticamera dell'ignoranza" (André La Vallette)

  6. #6
    Guarda, Dreamweaver ha fatto questa modifica senza toccare il cursore:
    <%
    Dim Rs_foto
    Dim Rs_foto_numRows

    Set Rs_foto = Server.CreateObject("ADODB.Recordset")
    Rs_foto.ActiveConnection = conn_artisti
    if Session ("lang") = "ita" then

    Rs_foto.Source = "SELECT Tabfoto.Idfoto, Tabfoto.Idartista, Tabfoto.Titoloita, Tabfoto.Fotopiccola, Tabartisti.Idartista, Tabartisti.Nome, Tabartisti.Cognome FROM Tabfoto, Tabartisti WHERE Tabfoto.Idartista LIKE Tabartisti.Idartista "
    else
    Rs_foto.Source = "SELECT Tabfoto.Idfoto, Tabfoto.Idartista, Tabfoto.Titoloeng, Tabfoto.Fotopiccola, Tabartisti.Idartista, Tabartisti.Nome, Tabartisti.Cognome FROM Tabfoto, Tabartisti WHERE Tabfoto.Idartista LIKE Tabartisti.Idartista "
    end if
    Rs_foto.CursorType = 0
    Rs_foto.CursorLocation = 2
    Rs_foto.LockType = 1
    Rs_foto.Open()

    Rs_foto_numRows = 0
    %>
    <%
    ' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

    Dim Rs_foto_total
    Dim Rs_foto_first
    Dim Rs_foto_last

    ' set the record count
    Rs_foto_total = Rs_foto.RecordCount

    ' set the number of rows displayed on this page
    If (Rs_foto_numRows < 0) Then
    Rs_foto_numRows = Rs_foto_total
    Elseif (Rs_foto_numRows = 0) Then
    Rs_foto_numRows = 1
    End If

    ' set the first and last displayed record
    Rs_foto_first = 1
    Rs_foto_last = Rs_foto_first + Rs_foto_numRows - 1

    ' if we have the correct record count, check the other stats
    If (Rs_foto_total <> -1) Then
    If (Rs_foto_first > Rs_foto_total) Then
    Rs_foto_first = Rs_foto_total
    End If
    If (Rs_foto_last > Rs_foto_total) Then
    Rs_foto_last = Rs_foto_total
    End If
    If (Rs_foto_numRows > Rs_foto_total) Then
    Rs_foto_numRows = Rs_foto_total
    End If
    End If
    %>

    <%
    ' *** Recordset Stats: if we don't know the record count, manually count them

    If (Rs_foto_total = -1) Then

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

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

    ' set the number of rows displayed on this page
    If (Rs_foto_numRows < 0 Or Rs_foto_numRows > Rs_foto_total) Then
    Rs_foto_numRows = Rs_foto_total
    End If

    ' set the first and last displayed record
    Rs_foto_first = 1
    Rs_foto_last = Rs_foto_first + Rs_foto_numRows - 1

    If (Rs_foto_first > Rs_foto_total) Then
    Rs_foto_first = Rs_foto_total
    End If
    If (Rs_foto_last > Rs_foto_total) Then
    Rs_foto_last = Rs_foto_total
    End If

    End If
    %>
    http://www.diemmedi.com
    --------------
    "La citazione è l'anticamera dell'ignoranza" (André La Vallette)

  7. #7
    non usare dreamweaver

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.