% '这个函数很关键!--------------------------- 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 %>