其實,主要精髓就是SQL語句的寫法上。 之前的提取為 "select * form whattable where id="&id 插入為 "insert into whattable(xx_rs) values(' "&content&" ')" 刪除為 "delete from whattable where id="&id 修改為 "update whattable set xx_rs=' "&log_content&" ' where id="&id 則查詢為 "select * form whattable where xx_rs like '%"&wahtkey&"%' "
<!--#include file="conn.asp" --> <% if request.form("submit")="search" then whatzip=request.form("zipcode") Set rs = Server.CreateObject ("ADODB.Recordset") sql = "Select * from zip where zipcode like '%"&whatzip&"%' " rs.Open sql,conn,1,1 %> <% if rs.EOF and rs.BOF then response.write ("未能查到") else Do Until rs.EOF response.write("<hr>該地址是:"& rs("placename")&rs("zipcode")) response.write("<br>所在省份是:"& rs("province")) rs.MoveNext Loop end if %> <br><a href="search.asp">again</a> <% rs.close Set rs = Nothing conn.close set conn=Nothing else %> <form action="search.asp" method="post"> <input type="text" name="zipcode"> <input type="submit" name="submit" value="search"> </form> <%end if%>
以上采用like意思表示進行模糊查詢,要精確查詢則直接使用 sql = "Select * from zip where zipcode = '%"&whatzip&"%' "