ASP - fejl i kode til søg i access
Jeg har en access database med:Id - Omraade - Titel - Foredragsholder - Region - Kommentar
___________________________________________________________
Jeg kan ikke rigtig få søgningen til at vise korrekt resultat
___________________________________________________________
INDEX.ASP
<form action="result.asp" method="POST">
<p><input type="TEXT" size="20" name="SEARCHTEXT"> <input type="submit" value="Søg"></p>
</form>
___________________________________________________________
RESULT.ASP
<!-- #INCLUDE file="opendb.asp" -->
<%
SetLocale("da")
SEARCHTEXT = Request("SEARCHTEXT")
If Len(SEARCHTEXT) = 0 Then
Response.Redirect("index.asp")
End If
SQL = "SELECT ID, Titel FROM FOREDRAGSHOLDERE WHERE Titel LIKE ? OR OMRAADE LIKE ? Or FOREDRAGSHOLDER LIKE ? OR REGION LIKE ? OR KOMMENTAR LIKE ? ORDER BY Titel, TITEL"
set comm = CreateObject("ADODB.Command")
comm.ActiveConnection = con
comm.CommandText = SQL
comm.Parameters.Item(0) = "%" & SEARCHTEXT & "%"
comm.Parameters.Item(1) = "%" & SEARCHTEXT & "%"
comm.Parameters.Item(2) = "%" & SEARCHTEXT & "%"
comm.Parameters.Item(3) = "%" & SEARCHTEXT & "%"
comm.Parameters.Item(4) = "%" & SEARCHTEXT & "%"
comm.Parameters.Item(5) = "%" & SEARCHTEXT & "%"
set recset = comm.Execute
%>
<%
If recset.EOF then
Response.Write("<br><br><center>Din søgning gav ingen resultat!</center>")
Else
While Not recset.EOF
Response.Write("<br><br><center><a href=""vis.asp?ID=" & recset("Id") & """>" & recset("Titel") & "</a></center>")
recset.MoveNext
Wend
End If
%>
<!-- #INCLUDE file="closedb.asp" -->
___________________________________________________________
VIS.ASP
<!-- #INCLUDE file="opendb.asp" -->
<%
SetLocale("da")
ID = Request("ID")
if Len(ID) < 1 then
Response.Redirect("index.asp")
elseif Not IsNumeric(ID) then
Response.Redirect("index.asp")
else
SQL = "SELECT * FROM FOREDRAGSHOLDERE WHERE ID=" & ID
set recset = con.Execute(SQL)
if recset.EOF then
Response.Redirect("index.asp")
end if
end if
Function DataTableRow(Label, Value)
Response.Write("<tr><td><b>" & Label & ":</b></td><td> </td><td>" & Value & "</td></tr>")
End Function
%>
<br><br><br><center><font face="Verdana" size="2"><b><u><% = recset("Omraade") %></u></b></font></center>
<table border="0" align="center"><br><br><br>
<%
DataTableRow "Omraade", recset("Omraade")
DataTableRow "Titel", recset("Titel")
DataTableRow "Foredragsholder", recset("Foredragsholder")
DataTableRow "Region", recset("Region")
DataTableRow "Kommentar", recset("Kommentar")
%>
</table>
<!-- #INCLUDE file="closedb.asp" -->
___________________________________________________________
jeg har stirret mig blind på det - og kan ikke finde fejlen - ka du?