简体   繁体   English

ASP Classic搜索多个

[英]ASP Classic searching multiple

Question: anyone have multiple searching coding using asp ? 问题:有人使用asp进行多个搜索编码吗? Can you share? 可以分享吗?

This is what I want to do.. 这就是我想做的..

There are 3 option or searching..by name, by location, by region 有3个选项或按名称,位置,地区搜索..

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 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM