SoFunction
Updated on 2025-04-08

ASP's simple solution to multiple query


'subject Information Title
'company The name of the company that posted the information
'content The content of the information posted
'address Company Address
'infomation Company Profile
'note Related instructions
All the above values ​​are submitted by FORM, and then the corresponding values ​​are obtained by: subject=trim(("subject")) etc.

<% 
'This function is very critical! --------------------------------------------------------------------------------------------------------------------------------
Function sql(a,b,sqls) 
if b<>"" then 'If the client does not submit this value, the corresponding SQL statement will not be generated.
sqls=sqls & " and " & a & " like '%" & b & "%'" 
end if 
sql=sqls 
End Function 
'-----------------------------------------------------------------------------------------------------------------------------
Set con_n=("") 
DBpath=("/database/") 
 "driver={Microsoft Access Driver (*.mdb)};pwd=;dbq=" & DBpath 
Set rs=("") 
sqls="select * from mytable where 1=1 " 
'The following calls the above function, and there are many calls (theoretically any)
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" 
 sqls,conn,3,2 
%>