<%
Dim database,conn,connstr
database= "Example.mdb" Database tutorial name
Set Conn=server.createobject ("Adodb.connection") ' Create Connection object
' Provider parameter sets the driver for the database, Access uses the OLE DB driver; The data source parameter sets the actual path and file name of the database
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (Database)
Conn.Open connstr ' Connect the database using the Open method
str= "ASP" keyword
Set Rs=server.createobject ("Adodb.recordset") ' Creates a Recordset object
' Query from the database for records containing STR in content
Sql= "SELECT * From example where content like '% ' &str& '% '"
Rs.Open sql,conn,1,3 ' Execute query, the result is saved in RS
If rs.eof or Rs.bof then ' does not exist record
Response.Write (' Alert (') does not contain a record for the keyword ASP! ')")
Response.End
Else
' Existence record
Response.Write "There is a:<br><br> in the database with a keyword ASP"
Do, not rs.eof ' loops show IDs for all records
%>
<%=RS ("id")%> <%=rs ("content")%><br>
<%
Rs.movenext
Loop
End If
Rs.close
Set rs=nothing
Conn.close
Set conn=nothing
%>