% '這個函數(shù)很關鍵!--------------------------- Function sql(a,b,sqls) if b>"" then '如果客戶端沒有提交此值,則不會產(chǎn)生相應的SQL語句。 sqls=sqls " and " a " like '%" b "%'" end if sql=sqls End Function '-----------------調(diào)用數(shù)據(jù)庫 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 " '以下調(diào)用上面的函數(shù)即可,可以很多個調(diào)用(理論上是任意) 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 %>