ASP Query records:
Learning Purpose: Learn the basic operation of database--query record
On the fourth day we use one of the following programs:
We're looking at all the records, but we're not going to be able to get all the records when we want to modify or delete the records, all of us have to learn to retrieve the right records. First look at a statement:
A= "AAA"
b=1111110
Exec= "SELECT * from guestbook where name= '" +a+ "' and Tel= ' +b
Where the following is the condition, with and, or, I think everyone knows the meaning of =,<=,>=,<,>. The search name is "AAA" and the phone is a record of "1111110". The other thing is if you're searching for a field that contains a string, you can write this: where InStr (Name,a) is the person who searches for the string of a (AAA) in name.
My a,b here, is a constant, you can let A,b is the form submitted to the variable, so you can do a search.
Let's take a look at this code and understand this: (Save the following code as a 6.htm file)
Search:
Name =
and tel=
Exam6.asp (Save the following code as exam6.asp)
<%
Do as not rs.eof
%>
<%
Rs.movenext
Loop
%>
<%=rs ("name")%> |
<%=rs ("tel")%> |
<%=rs ("message")%> |
<%=rs ("Time")%> |
First enter http://localhost/6.htm in the browser as shown in the following image:
Enter the name and phone aaa,1111110 that are already in the database, and click Submit, as shown in the following figure: