ASP 의 간결 한 다 중 조회 방법 과 함수 가 정말 좋 습 니 다.

ASP 간결 한 다 중 조회 솔 루 션

'subject   
'company   
'content   
'address   
'infomation   
'note   
FORM , :subject=trim(Request.Form("subject")) 。 
<% 
' !--------------------------- 
Function sql(a,b,sqls) 
if b<>"" then ' , SQL 。 
sqls=sqls & " and " & a & " like '%" & b & "%'" 
end if 
sql=sqls 
End Function 
'-----------------  
Set con_n=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 
%> 

좋은 웹페이지 즐겨찾기