Simple multi-query methods and functions under ASP are really good
Source: Internet
Author: User
ASP simple multi-query Solution
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
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.