First, understand the next principle.
1, provide text box to query the contents of the input
2, the query information submitted to the page program processing
3, the main role of the program page: to accept the query information, based on this information to invoke a specific SQL query statements, to obtain the results of the query and can be displayed.
In fact, the main essence is the wording of the SQL statement.
Before the
ExtractFor "select * Form whattable where id=" &id
InsertInsert into whattable (xx_rs) VALUES (' &content& ')
RemoveAs "delete from whattable where id=" &id
ModifyFor "Update whattable set xx_rs= '" &log_content& "where id=" &id
The
QueryFor "select * Form whattable where xx_rs like '% ' &wahtkey& '% '"
The following is an example to study
1, establish the ZIP table in the database Zipcode.mdb
Field ID, type autonumber (keyword)
field placename, type text
Field province, type text
field ZipCode, type text
Field borough, type text
2, add the database information content
ID AutoNumber, no need to join
placename corresponding counties and cities
Province corresponding Provinces
ZipCode corresponding ZIP code
Borough corresponding Area code
3, Connection file conn.asp
<% Db_path = "Zipcode.mdb" Set conn= Server.CreateObject ("ADODB.") Connection ") ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &server.mappath (Db_path) Conn. Open ConnStr %>
|
4, query input page search.asp
<textarea class="bk" id="temp52531" rows="12"><form action= "search.asp" method= "POST" > <input type= "text" name= "ZipCode" > <input type= "Submit" Name= "Submit" value= "search" > </form></textarea>
[Ctrl + a All choose to copy tips: You can modify some of the code, and then click to Run]
5, the Information query page, the same is search.asp
<!--#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 ("Failed to find") Else Do Until Rs. Eof Response.Write ("Response.Write ("<br> Province is:" & 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%>
|
The above uses the like meaning to carry on the fuzzy inquiry, wants the accurate inquiry to use directly
sql = "SELECT * from zip where zipcode = '% ' &whatzip& '% '"
Of course, through the area code query has not been added, you can try to improve yourself, or to a mixed query, separate query, fuzzy query and accurate query of the large synthesis.
Debug page.