WEB LISTING 2: SQLContactList.asp Begin Callout A <%@ Language=VBScript%> <% %>
<% dim sPageTitle dim sSort dim sWhere, sOrderBy dim rsContacts dim sSQL , sLastNameSelect server.scripttimeout = 30 %> 32X Tech Prospect List

Click a letter to filter contacts by last names that start with that letter:

End Callout A Begin Callout B <% sLastNameSelect = trim(request("LastNameSelect")) sSort = trim(request("sort")) sSQL = "SELECT * FROM Contact " if sLastNameSelect = "" THEN sLastNameSelect = "A" if sLastNameSelect <> "All" then sWhere = " WHERE LastName LIKE '" & trim(sLastNameSelect) & "%' " sSQL = sSQL & sWhere end if sOrderBy = "ORDER BY LastName, FirstName" End Callout B Begin Callout C SELECT case lcase(sSort) case "name": sSQL = sSQL & " ORDER BY LastName, FirstName" case "email": sSQL = sSQL & " ORDER BY email, lastname, firstname" case "company": sSQL = sSQL & " ORDER BY companyname, lastname, _ & firstname" case "location": sSQL = sSQL & " ORDER BY country, stateprovince,city, _ & lastname, firstname" case "phone": sSQL = sSQL & " ORDER BY phone, lastname, firstname" case "prospect": sSQL = sSQL & " ORDER BY ConsultingProspect Desc,_ & lastname, firstname" case else sSQL = sSQL & sOrderBy end SELECT Set rsContacts = RunWithRS(sSQL) %> End Callout C
Begin Callout D A B C D E F G H I J K L M N O P Q R S T U V W X Y Z | All Contacts Current filter is <%=sLastNameSelect%>
End Callout D

Begin Callout E

Click a column header (such as Email) to sort.

End Callout E Begin Callout F <% do while not rsContacts.eof %> <% rsContacts.movenext loop %>
Name Prospect (T/C) Email Company Location Phone Number

"> <%=rsContacts("LastName")%>, <%=rsContacts("FirstName")%> <%=rsContacts("TrainingProspect")%>, <%=rsContacts("ConsultingProspect")%> <%=rsContacts("email")%> <%=rsContacts("CompanyName")%> <%=rsContacts("City")%>, <%=rsContacts("StateProvince")%>,<%=rsContacts("country")%> <%=rsContacts("Phone")%>
 
End Callout F