How to select the record which we want to show by using SQL?
So, we will show a list of the members whose location is "LA". We will use SQL command.
The ASP codes are written and described as below:
<%
Set conn = Server.CreateObject("Adodb.Connection")
conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb")
Set rs = Server.CreateObject("Adodb.Recordset")
strSQL = "SELECT * FROM Member WHERE Location='LA'" 'We generate a SQL command that will show the member record which the location is LA
rs.Open strSQL ,conn,1,3 'We use the SQL command to open a Recordset, the Recordset will only had the member record that the location is LA
If rs.EOF Then 'If Eof is True; that means is not record
%>
<%
Else
Do while Not rs.eof
%>
<%
rs.movenext
Loop
End If
rs.Close
Set rs = Nothing
%>
No member... | |||
<%=rs("MemID")%> | <%=rs("MemberName")%> | <%=rs("Location")%> |
No comments:
Post a Comment