CopyCode The Code is as follows: 'subject information title
Name of the company whose company information is published
'Content content
'Address company address
'Infomation Company Profile
'Note
The preceding values are submitted by form and then obtained through: Subject = trim (request. Form ("subject.
<%
'The function is critical! ---------------------------
Function SQL (a, B, sqls)
If B <> "" then', if the client does not submit this value, no corresponding SQL statement is generated.
Sqls = sqls & "and" & A & "like '%" & B & "% '"
End if
SQL = sqls
End Function
'--------------- Call the database
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"
'Call the above function below, and you can call multiple (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"
Rs. Open sqls, Conn, 3, 2
%>
[Conclusion]
If there is no key function SQL (a, B, sqls), we can imagine the number of statements that need to be judged one by one!