% option explicit %>
<!-- #INCLUDE FILE="./adovbs.inc" --> <!-- #INCLUDE FILE="DbPath.inc" --> <% 'DbPath.inc is used to establish database connection 'copy and paste the source code , save this as wsdx-search.asp Dim strProduct strProduct = Request("txtProduct") Set Rs = Server.CreateObject("ADODB.Recordset") Rs.ActiveConnection = OBJdbConnection Rs.Source = "SELECT * FROM tblProduct WHERE productName like '%" & strProduct & "%';" Rs.Open 'this is added to check whether a record is found 'if there is no record then when first open, Rs.EOF will be true If Rs.EOF then Response.Write("Items not found") Else Response.Write("<table border='1'><tr><th>Product Name</th><th>Manufacturer</th><th>Price</th><th>Category</th></tr>") Do Until Rs.EOF Response.Write("<tr><td>" & Rs("productName") & "</td><td>" & Rs("manufacturer") & "</td><td>" & Rs("price") & "</td><td>" & Rs("productCategory") & "</td></tr>") Rs.MoveNext Loop Response.Write("</table>") End if Rs.Close Set Rs= Nothing %> <h3>Search by name</h3> <form name="frmSearchName" action="wsdx-search.asp" method="post"> <table> <tr> <td>Search by product name:</td> </tr> <tr> <td><input type="text" name="txtProduct" /></td> <td><input type="submit" value="Search" /></td> </tr> </table> </form>