URGENT - problem med søgeformular
Hej - Jeg har et meget akut problem med min søgefunktion - Den virker perfekt når jeg søger på \"all funktions\" med hvis jeg forsøger at søge i en bestemt database får jeg denne fejl:Microsoft JET Database Engine error \'80040e10\'
No value given for one or more required parameters
/foreignhelp/search.asp, line 174
(linie 174 er denne linie: rs.Open sSQL,,,adCmdTable
)
Please hjælp! jeg giver gerne flere points hvis I mener jeg har sat for få af.
Scriptet kommer her:
<br>
<p class=\"smallheader\">
Advanced Search
</p>
<%
sub ShowSearchForm
%>
<form action=\"search.asp?cmdSearch=1\" method=\"post\">
<table border=0 cellpadding=2 cellspacing=2>
<tr><td>
Enter your search words seperated by spaces.
</td></tr>
<tr><td>
<input type=\"text\" name=\"txtSearch\" value=\"<%=sSearch%>\" size=\"50\" maxlength=\"250\" class=\"tbflat\">
<input type=\"submit\" name=\"cmdSearch\" value=\"Search\" class=\"cmdflat\">
</td></tr>
<td>
<table border=0>
<tr><td>
Search type:
</td><td>
<%
dim aTypes(3)
aTypes(1) = \"All Words\"
aTypes(2) = \"Any Words\"
aTypes(3) = \"Exact Phrase\"
response.write \"<select name=\"\"cboType\"\" class=\"\"tbflat\"\">\"
for iType = 1 to 3
response.write \"<option value=\"\"\" & iType & \"\"\"\"
if iSearchType = iType then
response.write \" selected\"
end if
response.write \">\" & aTypes(iType) & \"</option>\"
next
%>
</td></tr>
<tr><td>
Search in
</td><td>
<select name=\"cboProject\" class=\"tbflat\">
<%
dim aProjects(3)
aProjects(0) = \"all funktions\"
aProjects(1) = \"Member Directory\"
aProjects(2) = \"Eksperten\"
aProjects(3) = \"Denmark A-Z\"
for iType = 0 to 3
response.write \"<option value=\"\"\" & iType & \"\"\"\"
if iProject = iType then
response.write \" selected\"
end if
response.write \">\" & aProjects(iType) & \"</option>\"
next
%>
</select>
</td>
</table>
</td>
</table>
</form>
<%
end sub
sub ShowResults
ShowUsers
ShowEkspert
ShowDenmark
end sub
sub ShowHeader(sHeaderText)
response.write \"<br>\"
response.write \"<table border=\"\"0\"\" cellpadding=\"\"0\"\" cellspacing=\"\"2\"\" width=\"\"100%\"\">\"
response.write \"<tr><td class=\"\"smallerheader\"\" bgcolor=\"\"#fdf5e6\"\">\" & sHeaderText & \"</td></tr>\"
end sub
sub ShowFooter
response.write \"</table>\"
end sub
sub ShowItem(sURL, sTitle, sDescription)
response.write \"<tr><td class=\"\"smallertext\"\">» <a href=\"\"\" & sURL & \"\"\">\" & sTitle & \"</a></td></tr>\"
end sub
function ConstructWhere(sFields)
select case iSearchType
case 1 \'All words
sWhere = ConstructWhereByFields (sFields, \" AND \")
case 2 \'Any words
sWhere = ConstructWhereByFields (sFields, \" OR \")
case 3 \'Exact Phrase
aFields = split(sFields, \",\")
for iField = 0 to ubound(aFields)
if bFieldBegin = true then
sExpr = \" OR \"
end if
sWhere = sWhere & sExpr & aFields(iField) & \" LIKE \'%\" & sSearch & \"%\'\"
bFieldBegin = True
next
end select
sWhere = \"(\" & sWhere & \")\"
if (iProject > 0 and bNoProjectID = false) then
if sTableDotField <> \"\" then
sWhere = sWhere & \" AND (\" & sTableDotField & \" = \" & iProject & \")\"
else
sWhere = sWhere & \" AND (ProjectID = \" & iProject & \")\"
end if
end if
ConstructWhere = sWhere
end function
function ConstructWhereByFields(sFields, sWordExpr)
aFields = split(sFields, \",\")
aWords = split(sSearch, \" \")
bFieldBegin = false
for iField = 0 to ubound(aFields)
if bFieldBegin = true then
sExpr = \" OR \"
end if
bWordBegin = false
for iWord = 0 to ubound(aWords)
if bWordBegin = false then
sWhere = sWhere & sExpr & \"(\" & aFields(iField) & \" LIKE \'%\" & aWords(iWord) & \"%\'\"
else
sWhere = sWhere & sWordExpr & aFields(iField) & \" LIKE \'%\" & aWords(iWord) & \"%\'\"
end if
bWordBegin = True
next
bFieldBegin = True
sWhere = sWhere & \")\"
next
ConstructWhereByFields = sWhere
end function
\'**********************************************************************
\'MEMBER DIRECTORY
sub ShowUsers
OpenDB sConnUsers
sFields = \"username,firstname,lastname,countrycode,email\"
sWhere = ConstructWhere (sFields)
sSQL = \"SELECT * FROM Users WHERE \" & sWhere
rs.Open sSQL,,,adCmdTable
if not (rs.eof or rs.bof) then
ShowHeader \" :: Member Directory\"
response.write \"<tr><td class=\"\"smallertext\"\">\"
do while not rs.eof
sURL = \"/foreignhelp/community/member_directory/showuser.asp?BrugerID=\" & rs(\"BrugerID\")
sTitle = rs(\"Firstname\") & \" \" & RS(\"lastname\") & \" \" & RS (\"countryCode\")
response.write \"» <a href=\"\"\" & sURL & \"\"\">\" & sTitle & \"</a> \"
rs.movenext
iResultCount = iResultCount + 1
loop
response.write \"</td><tr>\"
ShowFooter
end if
rs.close
conn.close
end sub
\'*************************************************************************************************
\' DENMARK A-Z
sub ShowDenmark
OpenDB sConnUsers
sFields = \"adresse,om,website,catnavn\"
sWhere = ConstructWhere (sFields)
sSQL = \"SELECT * FROM Denmark WHERE \" & sWhere
rs.Open sSQL,,,adCmdTable
if not (rs.eof or rs.bof) then
ShowHeader \" :: Denmark A-Z \"
response.write \"<tr><td class=\"\"smallertext\"\">\"
do while not rs.eof
sURL = \"/foreignhelp/channels/denmark/showuser.asp?ID=\" & rs(\"ID\")
sTitle = rs(\"catnavn\")
response.write \"» <a href=\"\"\" & sURL & \"\"\">\" & sTitle & \"</a> \"
rs.movenext
iResultCount = iResultCount + 1
loop
response.write \"</td><tr>\"
ShowFooter
end if
rs.close
conn.close
end sub
\'**********************************************************************************
sub ShowEkspert
OpenDB sConnExpert
sFields = \"ID,overskrift\"
sWhere = ConstructWhere (sFields)
sSQL = \"SELECT * FROM spm WHERE \" & sWhere & \" ORDER BY dato DESC\"
rs.Open sSQL,,,adCmdTable
if not (rs.eof or rs.bof) then
ShowHeader \" :: Questions to our Experts\"
response.write \"<tr><td class=\"\"smallertext\"\">\"
do while not rs.eof
sURL = \"/foreignhelp/projects/bugs.asp?pid=\" & rs(\"ID\") & \"#\" & rs(\"ID\")
sTitle = rs(\"overskrift\")
ShowItem sURL, sTitle, sDescription
iResultCount = iResultCount + 1
rs.movenext
loop
response.write \"</td><tr>\"
ShowFooter
end if
rs.close
conn.close
end sub
sub ShowSummary
if iResultCount > 0 then
response.write \"<table border=\"\"0\"\" width=\"\"100%\"\"><tr><td bgcolor=\"\"#fdf5e6\"\">\" & _
\"Total <strong>\" & iResultCount & \"</strong> results found.\" & _
\"</td></tr></table>\"
else
response.write \"<table border=\"\"0\"\" width=\"\"100%\"\"><tr><td bgcolor=\"\"#fdf5e6\"\">\" & _
\"Nothing found ;)\" & _
\"</td></tr></table>\"
end if
end sub
function CheckString(sText)
sText = replace(sText, \"\'\", \"\")
sText = replace(sText, \"\"\"\", \"\")
sText = replace(sText, \"[\", \"\")
sText = replace(sText, \"]\", \"\")
sText = replace(sText, \"%\", \"\")
CheckString = sText
end function
sub InitSearch
sSearch = CheckString(request(\"txtSearch\"))
iSearchType = CLng(request(\"cboType\"))
iProject = CLng(request(\"cboProject\"))
if iSearchType = 0 then iSearchType = 1
end sub
dim sSearch
dim iSearchType
dim iProject
dim iResultCount
dim sTableDotField
dim bNoProjectID
InitSearch
if request(\"cmdSearch\") = \"\" OR len(sSearch) = 0 then
ShowSearchForm
else
ShowResults
ShowSummary
ShowSearchForm
end if
set rs = nothing
set conn = nothing
%>
<br><br>
