har gjort en liten sökfunktion för att söka efter användare men den vill inte fungera riktigt, antingen så hittar den inga användare eller så kommer felmeddelande upp: Du har glömt omge datomet med #. Tolkas som en subtraktion mellan talen.sökfunktion
Koden:
<code>
if usertype = "exact" then
strsql = "select * from tblinfo where fldusername = '"&username&"' And fldBirthDate < "&DateAdd("yyyy", -CInt(request("frmAgeMin")), Date)&" And fldBirthDate > "&DateAdd("yyyy", -CInt(request("frmAgeMax")), Date)&""
elseif usertype = "almost" then
strsql = "select * from tblinfo where fldusername like '"&username&"%' And fldBirthDate < "&DateAdd("yyyy", -CInt(request("frmAgeMin")), Date)&" And fldBirthDate > "&DateAdd("yyyy", -CInt(request("frmAgeMax")), Date)&""
end if
if hometype = "exact" then
strsql = strsql & " and fldtown = '"&hometown&"'"
elseif hometype = "almost" then
strsql = strsql & " and fldtown like '"&hometown&"%'"
else
end if
if emailtype = "exact" then
strsql = strsql & " and fldemail = '"&email&"'"
elseif emailtype = "almost" then
strsql = strsql & " and fldemail like '"&email&"%'"
else
end if
if gendertype = "girls" then
strsql = strsql & " and fldgender = 'f'"
elseif gendertype = "boys" then
strsql = strsql & " and fldgender = 'p'"
else
end if
if online = "on" then
strsql = strsql & " and fldonline = '1' order by fldusername DESC"
else
strsql = strsql &" order by fldusername DESC"
end if
rs.open strsql, connect, 3, 3
if rs.eof then
call font2
response.write "Hittade inga användare</font>"
else
do until rs.eof
--- Skriver ut koden ---
rs.movenext
loop
end if
</code>
har skrivit ut sqlkoden när jag använder alla fält och får följande resultat:
select * from tblinfo where fldusername like 'jo%' And fldBirthDate < 1993-01-08 And fldBirthDate > 1903-01-08 and fldtown like 'tid%' and fldemail like 'jonny%' and fldgender = 'p' and fldonline = '1' order by fldusername DESC
och felmeddelandet blir:
Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
search/search_result.asp, line 208
Rad 208: rs.open strsql, connect, 3, 3
Någon som har en aning om vad jag ska ändra på för att det ska fungera?Sv: sökfunktion
<code>
Select Case usertype
Case "exact"
strsql = "SELECT *" & vbCrLf & _
"FROM tblinfo" & vbCrLf & _
"WHERE fldusername = '" & username & "' And " & vbCrLf & _
" fldBirthDate < #" & DateAdd("yyyy", -CInt(request("frmAgeMin")), Date) & "# And " & vbCrLf & _
" fldBirthDate > #" & DateAdd("yyyy", -CInt(request("frmAgeMax")), Date) & "#"
Case "almost" then
strsql = "SELECT *" & vbCrLf & _
"FROM tblinfo" & vbCrLf & _
"WHERE fldusername like '" & username & "%' And " & vbCrLf & _
" fldBirthDate < #" & DateAdd("yyyy", -CInt(request("frmAgeMin")), Date) & "# And " & vbCrLf & _
" fldBirthDate > #" & DateAdd("yyyy", -CInt(request("frmAgeMax")), Date) & "#"
End Select
if hometype = "exact" then
strsql = strsql & " and fldtown = '"&hometown&"'"
elseif hometype = "almost" then
strsql = strsql & " and fldtown like '"&hometown&"%'"
end if
if emailtype = "exact" then
strsql = strsql & " and fldemail = '"&email&"'"
elseif emailtype = "almost" then
strsql = strsql & " and fldemail like '"&email&"%'"
end if
if gendertype = "girls" then
strsql = strsql & " and fldgender = 'f'"
elseif gendertype = "boys" then
strsql = strsql & " and fldgender = 'p'"
end if
if online = "on" then
strsql = strsql & " and fldonline = '1' order by fldusername DESC"
else
strsql = strsql &" order by fldusername DESC"
end if
rs.open strsql, connect, 3, 3
if rs.eof then
call font2
response.write "Hittade inga användare</font>"
else
do until rs.eof
--- Skriver ut koden ---
rs.movenext
loop
end if
</code>