<% '这个函数很关键!--------------------------- Function sql(a,b,sqls) if b<>"" then '如果客户端没有提交此值,则不会产生相应的SQL语句。 sqls=sqls & " and " & a & " like '%" & b & "%'" end if sql=sqls End Function '-----------------调用数据库 Set conn=Server.CreateObject("ADODB.Connection") DBpath=Server.MapPath("/database/mydb.mdb") Conn.Open "driver={Microsoft Access Driver (*.mdb)};pwd=;dbq=" & DBpath Set rs=Server.CreateObject("ADODB.Recordset") sqls="select * from mytable where 1=1 " '以下调用上面的函数即可,可以很多个调用(理论上是任意) sqls=sql("subject",subject,sqls) sqls=sql("company",company,sqls) sqls=sql("content",content,sqls) sqls=sql("address",address,sqls) sqls=sql("infomation",infomation,sqls) sqls=sql("note",note,sqls) sqls=sqls & " order by id desc" rs.open sqls,conn,3,2 %>
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved 京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089