Buongiorno a tutti,
navogando sul motore di ricerca ho trovato questo topic che spiegava come creare un motore di ricerca con più campi a combinazione.
In pratica se ho varie scelte tipo marca, modello, prezzo di una macchina posso fare la ricerca inserendo tutti, o alcuni di questi dati.
il codice è questo:
<%
' INIZIO IL CONTROLLO
set RsModello = Server.CreateObject("ADODB.Recordset")
sqlmodello = "Select * from Auto"
where = ""
sep = ""
if stato <> "Tutti" then
where = "Stato=" & stato
sep = "and"
end if
if categoria <> "Tutte" then
where = where & sep & "Categoria=" & categoria
sep = "and"
end if
if marca <> "Tutte" then
where = where & sep & "Marca=" & marca
sep = "and"
end if
if modello <> "Tutti" then
where = where & sep & "Modello=" & modello
sep = "and"
end if
if prezzo <> "Tutti" and prezzo <> "4" then
where = where & sep & "Prezzo <=" & prezzo
sep = "and"
end if
if prezzo = "4" then
where = where & sep & "Prezzo >=" & prezzotot
sep = "and"
end if
if anno <> "Tutti" then
where = where & sep & "Anno=" & anno
sep = "and"
end if
if carburante <> "Tutti" then
where = where & sep & "Carburante=" & carburante
sep = "and"
end if
'...
'...
if where <>"" then
sqlmodello = sqlmodello & " WHERE " & where
end if
RsModello.open sqlmodello, connobj
%>
Quando per la ricerca utilizzo la scritta Tutti mi trova tutte le vetture nel database,
se per caso per Stato inserisco Nuovo, mi da questo errore:
Tipo di errore:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][Driver ODBC Microsoft Access] Parametri insufficienti. Previsto 1.
/checksearch1.asp, line 60
Se per caso faccio una ricerca per prezzo tutto funziona, c'è da dire che nel database in access il campo prezzo è Numerico mentre tutti gli altri campi sono Testo...
Qualcuno ci capisce qualcosa?
![]()

Rispondi quotando
