Ja, så er du ude på lidt af et skråplan. Så skal du jo først have fat i databasen og derefter:
If IsNumeric(Request.Form("xxx")) Then SQL = "SELECT tal FROM Tabel WHERE tal <= " & Request.Form("xxx") rs.Open SQL, conn, 3, 3 Do While NOT rs.EOF Response.Write rs("Tal") rs.MoveNext Loop rs.Close Else Response.Write "Du skal skrive et tal" End If
men soes har ret du kan ik bruge <= når du tilføjer til en variable hvis du har msn kan du adde mig colg@fragz.dk så kan du sende filen og jeg skal hjælpe dig
Det er sgu nok mig som formulere mit spørgsmål godt nok, så her er hele min kode så er det nok nemmere at forstå:
Dim privatforh, tybe, maerke, model, aargang, km, pris privatforh = Request.Form("privatforh") tybe = Request.Form("tybe") maerke = Request.Form("region") model = Request.Form("model") aargang = Request.Form("aargang") km = Request.Form("km") pris = Request.Form("pris")
If privatforh = "Forhandler/privat" then privatforh = "" End If
If aargang = "Årgang" then aargang = "" End If
If km = "Max antal km" then km = "" End If
If km <> "" then km <= Request.Form("km") End If
If pris = "Max pris" then pris = "" End If
sql = "SELECT * FROM biler WHERE privatforh LIKE '%" & privatforh & "%' And tybe LIKE '%" & tybe & "%' And maerke LIKE '%" & maerke & "%' And model LIKE '%" & model & "%' And km LIKE '%" & km & "%' And aargang LIKE '%" & aargang & "%' And pris LIKE '%" & pris & "%'" Set rs = Conn.Execute(sql)
Dim privatforh, tybe, maerke, model, aargang, km, pris privatforh = Request.Form("privatforh") tybe = Request.Form("tybe") maerke = Request.Form("region") model = Request.Form("model") aargang = Request.Form("aargang") km = Request.Form("km") pris = Request.Form("pris")
If privatforh = "Forhandler/privat" then privatforh = "" End If
If aargang = "Årgang" then aargang = "" End If
If km = "Max antal km" then km = "" End If
If km <> "" then km = Request.Form("km") End If
If pris = "Max pris" then pris = "" End If
sql = "SELECT * FROM biler WHERE privatforh LIKE '%" & privatforh & "%' And tybe LIKE '%" & tybe & "%' And maerke LIKE '%" & maerke & "%' And model LIKE '%" & model & "%' And km <=" & km & " And aargang LIKE '%" & aargang & "%' And pris LIKE '%" & pris & "%'" Set rs = Conn.Execute(sql)
det virker hvis der kun bliver indtastet noget i km men hvis jeg kun indtaster noget i f.eks. pris får jeg dette:
Fejltype: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) [Microsoft][ODBC Microsoft Access-driver] Der er en syntaksfejl, fordi der mangler en operator. i forespørgselsudtrykket "privatforh LIKE '%%' And tybe LIKE '%Personbil%' And maerke LIKE '%%' And model LIKE '%%' And km <= And aargang LIKE '%%' And pris LIKE '%%'". /autoshopping2/findcar.asp, line 88
Dim privatforh, tybe, maerke, model, aargang, km, pris privatforh = Request.Form("privatforh") tybe = Request.Form("tybe") maerke = Request.Form("region") model = Request.Form("model") aargang = Request.Form("aargang") km = Request.Form("km") pris = Request.Form("pris")
If privatforh = "Forhandler/privat" then privatforh = "" End If
If aargang = "Årgang" then aargang = "" End If
If km = "Max antal km" then km = "" End If
If LEN(km) <= 0 Then km = "" Else km = "km <= " & km End If
If pris = "Max pris" then pris = "" End If
sql = "SELECT * FROM biler WHERE privatforh LIKE '%" & privatforh & "%' And tybe LIKE '%" & tybe & "%' And maerke LIKE '%" & maerke & "%' And model LIKE '%" & model & "%' And " & km & " And aargang LIKE '%" & aargang & "%' And pris LIKE '%" & pris & "%'" Set rs = Conn.Execute(sql)
Dim privatforh, tybe, maerke, model, aargang, km, pris privatforh = Request.Form("privatforh") tybe = Request.Form("tybe") maerke = Request.Form("region") model = Request.Form("model") aargang = Request.Form("aargang") km = Request.Form("km") pris = Request.Form("pris")
If privatforh = "Forhandler/privat" then privatforh = "" End If
If aargang = "Årgang" then aargang = "" End If
If km = "Max antal km" then km = "" End If
If LEN(km) <= 0 Then km = "" Else km = " AND km <= " & km End If
If pris = "Max pris" then pris = "" End If
sql = "SELECT * FROM biler WHERE privatforh LIKE '%" & privatforh & "%' And tybe LIKE '%" & tybe & "%' And maerke LIKE '%" & maerke & "%' And model LIKE '%" & model & "%'" & km & " And aargang LIKE '%" & aargang & "%' And pris LIKE '%" & pris & "%'" Set rs = Conn.Execute(sql)
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.