< pre>Dim searchKeywords
searchKeywords = Trim(Request.Form("keywords"))
Dim conn, cmd, rs
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB; Data Source=服务器名; Initial Catalog=数据库名; User ID=用户名; Password=密码"
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = conn
cmd.CommandText = "SELECT * FROM Products WHERE Name LIKE '%" & searchKeywords & "%'"
cmd.CommandType = adCmdText
Set rs = cmd.Execute pre>
< pre>Dim searchKeywords
searchKeywords = Trim(Request.Form("keywords"))
Dim conn, cmd, rs
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB; Data Source=服务器名; Initial Catalog=数据库名; User ID=用户名; Password=密码"
Dim sqlLog
sqlLog = "INSERT INTO SQLLog (SQLStatement) VALUES ('" & Replace(cmd.CommandText, "'", "''") & "')"
conn.Execute sqlLog
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = conn
cmd.CommandText = "SELECT * FROM Products WHERE Name LIKE '%" & searchKeywords & "%'"
cmd.CommandType = adCmdText
Set rs = cmd.Execute pre>