|
TheMythe -> RE: the LIKE command does not work... (10/6/2005 4:14:12)
|
Okay, So now it returns a valid SQL-statement to my knowledge:
strQuery = "SELECT * FROM stavoor WHERE " & strField & " '%" & strOprtr & "%' " & strVal & " ORDER BY nummer"
response.write strQuery
response.end
rsCommon.Open strQuery, strCon, , , adCmdText
if not rsCommon.EOF then %>
Answers: SELECT * FROM stavoor WHERE nummer '%=%' 6 ORDER BY nummer However, it shows only the SQL-statement but the problem remains. At this point I'm thinking I got one of the variabels wrong, question is, which one? Perhaps: strOprtr? Here is the complete code again:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>uitgebreide zoekpagina</title>
</head>
<body background="../../19sept/henri4/Deventer2004.jpg" bgproperties="fixed">
<!-- #include file="connection modulair.asp" -->
<%
strQuery = "SELECT * FROM stavoor"
rsCommon.Open strQuery, strCon, , , adCmdText %>
<form method="post">
<select name="strField">
<% for each field in rsCommon.Fields %>
<option><%= field.Name %>
<% next %>
</select>
<select name="strOprtr">
<option>=
<option>>=
<option>>
<option><=
<option><
<option>LIKE
</select>
<input name="strVal">
<input type="submit" value="Geef weer">
<% rsCommon.Close %>
</form>
<% if not isEmpty(Request("strField")) then
strField=Request("strField")
strOprtr=Request("strOprtr")
if Request("strField")="nummer" then
strField="nummer"
strVal=Request("strVal")
elseif Request("strField")="prijs" then
strVal=Request("strVal")
else
strVal="'"&Request("strVal")&"'"
end if %>
<h5>. . . de volgende items zijn uit de Stavoor database gehaald: <%=strField%> <%=strOprtr%> <%=strVal%></h5>
<% 'define the query
strQuery = "SELECT * FROM stavoor WHERE " & strField & " '%" & strOprtr & "%' " & strVal & " ORDER BY nummer"
rsCommon.Open strQuery, strCon, , , adCmdText
if not rsCommon.EOF then %>
<table width=90% cellspacing=1 cellpadding=5 border=0>
<!-- begin column headers -->
<tr><% for each field in rsCommon.Fields %>
<th><%= field.Name %></th>
<% next %></tr>
<% 'cycle thru the record set and display each row results
do until rsCommon.EOF %>
<tr><% for each field in rsCommon.Fields %>
<% if field.Type = 5 or field.Type = 6 then %>
<td align="right">
<% else %>
<td>
<% end if %>
<%= field.Value %></td>
<% next %></tr>
<!-- next row = next record -->
<% 'increment record position with MoveNext method
rsCommon.MoveNext
loop %>
</table>
<p>De SQL statement luidt als volgt:</p>
<blockquote><h5><%= rsCommon.Source %></h5></blockquote>
<p><a href="#">Naar boven</a></p>
<% else %>
<blockquote>Niets gevonden, probeer nogmaals...</blockquote>
<% 'close record set and flush object from memory
rsCommon.Close
set rsCommon = Nothing
adoCon.close
set adoCon = Nothing
end if
end if %>
</body>
</html>
Again, thanks in advance for whoever reads or replies to this.
|
|
|
|