ASP Classic searching multiple
Question: anyone have multiple searching 开发者_StackOverflow社区coding using asp ? Can you share?
This is what I want to do..
There are 3 option or searching..by name, by location, by region
For the first display all data with paging..on top it has searching.
<textfield>name</textfield><list/menu>location</list/menu><list/menu>region</list/menu>
when search by region it will display all region are selected. Then it allow to filter by name to get specific
<%
Dim adoCon
Dim rsGuestbook
Dim strSQL
Dim lngRecordNo
lngRecordNo = CLng(Request.QueryString("ID"))
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database'
strSQL = "SELECT * FROM tbl_Master WHERE ID=" & lngRecordNo
rsGuestbook.Open strSQL, oConn
%>
Here is a querystring search be name,department,age. It works properly. It might help you. Just fetch your values. Put those in proper places. And don't forget to change your tablename
name1=request.QueryString("name")
dept1=request.QueryString("dept")
age1=request.QueryString("age")
sqlStr="Select * from Student_Entry"
sqlWhere=""
if name1<>"" then
sqlWhere = " Where S_name='"&name1&"'"
end if
if dept1<>"" then
if sqlWhere = "" then
sqlWhere = " Where S_dept='"&dept1&"'"
else
sqlWhere = sqlWhere&" And S_dept='"&dept1&"'"
end if
end if
if age1<>"" then
if sqlWhere = "" then
'sqlWhere = " Where S_age="&age1&""
sqlWhere = " Where S_age"&agestr&age1
else
'sqlWhere = sqlWhere&" And S_age="&age1&""
sqlWhere =sqlWhere&" And S_age"&agestr&age1
end if
end if
sqlStr = sqlStr & sqlWhere
it sounds like you are describing multiple dependent lists (?)
there is an example here with demo:
http://www.aspkey.net/aspkey/_articles/asp/showarticle.asp?id=100
strname , strlocation and strregion value will depend on selection if not select then default value will be "".
strSQL = "SELECT * FROM tbl_Master WHERE ID=" & lngRecordNo
if strname <> "" THEN
strSQL = strSQL & " and name ='"& strname &"' "
END IF
if strlocation <> "" THEN
strSQL = strSQL & " and location='"& strlocation &"'
END IF
if strregion <> "" THEN
strSQL = strSQL & " and region='"& strregion &"'
END IF
rsGuestbook.Open strSQL, oConn
精彩评论