Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12
  1. #1

    Form di ricerca da asp jscript a vbscript

    Ciao a tutti
    ho trovato un form di ricerca che funziona, ma è in asp jscript. il mio sito è in vbscript. ho fatto la "traduzione" manuale dall'uno all'altro ma devo aver perso qualche passaggio tant'è che mi restituisce l'errore
    Microsoft VBScript compilation error '800a0400'

    Expected statement

    codice:
    <<%
        dim testo
    	testo = (Request.Form("stringa"))
        dim apice 
    	apice = replace(testo,"'","''")
        dim stringa
    	stringa = split(apice," ")
    
    		if (testo = "" OR testo = "undefined") then
    			Response.Write("
    
    Inserire almeno una parola per effettuare una ricerca!</p>")
    		else
    			dim rs_ricerca
    			Set rs_ricerca = Server.CreateObject("ADODB.Connection")
    			rs_ricerca.ActiveConnection = MM_conn_chitarre_STRING
    			dim sql
    			sql = "SELECT * FROM q_principale_attiva WHERE"
    			
    			dim i
    			i=0	
    			for i = 0 to len(stringa)
    				if (i > 0) then
    					sql = " AND"
    				end if
    			sql = " ricerca LIKE '%" + stringa(i) + "%'"
    			
    			dim Mostra
    			Mostra = rs_ricerca.Execute(sql)
    				
    				if (Mostra.EOF) then
    					Response.Write("
    
    Nessun risultato</p>")
    				else
    							
    					Response.Write("
    
    ")
    					Response.Write(Mostra("modello") + "
    ")
    					Response.Write(Mostra("descrizione"))
    					Response.Write("</p>")
    						
    				end if	
    				
    			rs_ricerca.Close()
    			Set rs_ricerca = Nothing
    		
    		end if
    	
    %>
    questo è il mio codice, qualcuno saprebbe dirmi dov'è l'errore?

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    manca il NEXT prima di Dim Mostra

    E poi questa
    sql = " AND"

    secondo me dovrebbe essere
    sql = sql &" AND"

    Roby

  3. #3
    grazie mille... perfetto... c'era anche qualche altro errore che ho corretto, uno però non riesco a sistemarlo...

    Microsoft VBScript runtime error '800a01b6'

    Object doesn't support this property or method: 'EOF'

    la linea è

    if (Mostra.EOF) then

    sapresti dirmi come scriverlo...

  4. #4
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Togli le parentesi e poi:

    set Mostra = rs_ricerca.Execute(sql)

    Roby

  5. #5
    perfetto funziona

    ma quando vado a ciclarlo (sempre tentando di tradurre il codice jscript) mi da un errore

    Microsoft VBScript compilation error '800a0400'

    Expected statement

    end if

    riposto il codice aggiornato

    codice:
    <%
        var cerca = new String(Request("cerca"));
        var testo = new String(Request.Form("stringa"));
        var apice = testo.replace(/'/g,"''");
        var stringa = apice.split(" ");
        if (cerca == "OK")
        {
            if (testo == "" || testo == "undefined")
            {
                Response.Write("
    
    Inserire almeno una parola per effettuare una rcerca</p>");
            }
            else
            {
                var Cn = new ActiveXObject("ADODB.Connection");
                    Cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("chitarre.mdb"));
                var sql = "SELECT * FROM q_principale_attiva WHERE";
                for (var i=0; i<stringa.length; i++)
                {
                    if (i > 0)
                    {
                        sql += " AND";
                    }
                    sql += " ricerca LIKE '%" + stringa[i] + "%'";
                }
                var Mostra = Cn.Execute(sql);
                if (Mostra.EOF)
                {
                    Response.Write("
    
    Nessun risultato</p>");
                }
                else
                {
                    while (!Mostra.EOF)
                    {
                        with (Response)
                        {
                            Write("
    
    ");
                            Write("" +Mostra("modello") + "
    ");
                            Write(Mostra("descrizione"));
                            Write("</p>");
                            Mostra.MoveNext();
                        }
                    }
                }
                Cn.Close();
            }
        }
    %>

  6. #6
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Questa è la versione jscript....

    Roby

  7. #7
    che bigolo che sono...

    codice:
    <%
        dim testo
    	testo = (Request.Form("stringa"))
        dim apice 
    	apice = replace(testo,"'","''")
        dim stringa
    	stringa = split(apice," ")
    
    		if (testo = "" OR testo = "undefined") then
    			Response.Write("
    
    Inserire almeno una parola per effettuare una ricerca!</p>")
    		else
    			dim rs_ricerca
    			Set rs_ricerca = Server.CreateObject("ADODB.Connection")
    			rs_ricerca.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("../mdb-database/chitarre.mdb"))			
    			dim sql
    			sql = "SELECT * FROM q_principale_attiva WHERE"
    			
    			dim i
    			i=0	
    			for i = 0 to Ubound(stringa)
    				if (i > 0) then
    					sql = sql & " AND"
    				end if
    			sql = sql & " ricerca LIKE '%" + stringa(i) + "%'"
    			
    			next
    			dim Mostra
    			set Mostra = rs_ricerca.Execute(sql)
    				
    				if Mostra.EOF then
    					Response.Write("
    
    Nessun risultato</p>")
    				else
    				
    					Do while not Mostra.EOF
    					Response.Write("
    
    ")
    					Response.Write(Mostra("modello") + "
    ")
    					Response.Write(Mostra("descrizione"))
    					Response.Write("</p>")
    					Mostra.MoveNext()	
    				
    				end if	
    				
    			rs_ricerca.Close()
    			Set rs_ricerca = Nothing
    		
    		end if
    	
    %>

  8. #8
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Prova a sostituire i + con &
    Possibile non ti dica la riga dell'errore???

    Roby

  9. #9
    ho sostituito i + con & ma non è cambiato nulla...

    la linea è la 55, quella dell'ultimo end if

  10. #10
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Mah a me sembra corretto.

    Roby

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.