Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Record random

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2004
    Messaggi
    334

    Record random

    Ciao a tutti!!
    Sto provando questo script x l’estrazione casuale di un record. Sembra funzionare le prime due tre volte che aggiorno la pagina ma dopo si visualizza questo errore: Provider (0x80004005) Errore non specificato. /random/index.asp, line 8

    Alla riga 8 c’è la connessione del db, cosa significa questo errore?


    Lo script è questo:

    codice:
    <%@LANGUAGE = JScript%>
    <%
        
        var Cn = new ActiveXObject("ADODB.Connection");
        var Rs = new ActiveXObject("ADODB.Recordset");
    
    
        Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("database.mdb"));
        Rs.Open("SELECT nome FROM persone", Cn, 3, 3);
    
        
        var Quanti = parseInt(Rs.RecordCount);
        Rs.MoveFirst();
    
        
        var Casuale = parseInt(Math.random() * Quanti);
        Rs.Move(Casuale); 
        Response.Write(Rs("nome") +"
    ")
    
    
        Rs.Close();
        Cn.Close();
    %>
    Graxie a tutti

  2. #2
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400
    codice:
    <%
    ID = Request.QueryString("id")
    IF ID = "" THEN
    	ID = 0
    END IF
    
    SELECT CASE ID
    	CASE 0    ' Quando è il primo accesso
    
    
    open_recordset rs_getQuote,"select * from quote"
    open_recordset	rs,"select * from idate"
    
    if month(now()) < 10 then
       imonth = "0"& month(now())
    else
    	imonth =  month(now())
    end if
    idate1 = day(now()) & "/" & imonth & "/" & year(now())
    
    idate2 = formatdatetime(rs("iday"),2)
    rs.close
    
    Randomize Timer
    intRnd = (Int(RND * rs_getQuote.RecordCount))
    
    if iquote_of_the_day = "1" then
    	if idate1 <> idate2 then
    	    sql_update = "update config set config_value="&intRnd&" where config_variable = 'number_quote_of_the_day' "
    	    conn.Execute(sql_update)	
    	    sql_update = "update idate set iday='"&now()&"'"
    	    conn.Execute(sql_update)	
    	    rs_getQuote.Move intRnd
    	else	
    		rs_getQuote.Move inumber_quote_of_the_day
    	end if
    else
    	if session("id") = intRnd then
    	   do while session("id") = intRnd
    	   	  intRnd = (Int(RND * rs_getQuote.RecordCount))
    	   loop
    	end if
    	rs_getQuote.Move intRnd
    	session("id") = intRnd
    end if
    
    campoMemo=replace(rs_getQuote("quote"),chr(13),"
    ")
    			strCitazione = Mid(campoMemo,1,3000)
    			strAutore = rs_getQuote("author")
    			ID = rs_getQuote("id")
    			strLink = "<span class='testo'>"& strCitazione & "</span><a href='index.asp?id="& ID &"' target='_self'>
    ....Leer más....</a>" 
    
    	CASE ELSE   ' Quando si è cliccato su continua per visualizzare il resto della frase
    			open_recordset rs_getQuote,"select * from quote where ID = " & ID		
    
    			campoMemo=replace(rs_getQuote("quote"),chr(13),"
    ")
    			strCitazione = campoMemo
    			strAutore = rs_getQuote("author")
    			strLink = "<span class='testo'>"& strCitazione & "</span>"		
    			strLink = strLink & "
    <a href='index.asp' target='_self'>
    
    estrai altro record</a>"
    
    END SELECT
    
    
    %>
    prova questo

  3. #3
    Utente di HTML.it
    Registrato dal
    Nov 2004
    Messaggi
    334
    ciao wegawhite ti ringrazio, veramente cercavo qualcosa di piu semmblice ...

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.