Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2005

    Question Unanswered: Restricted search

    I am a bit new with asp. I am writing a search script associated with MS Access. The script searchs and displays the results, but it restricts what it will search. For example.

    I have a colomn named "Drug" - lets say there are 4 drugs that start with a, and I type a in the search box. It will only display 1 drug. It also only search the first word as well. Lets say there is a drug name "Acyclovir (intravenous)" and "Acyclovir (oral)" It will only be able to search from "Acyclovir". And if I type in "Acyclovir" It will only show one of them" If you can help me it would be greatly apreciated.

    Here is the code:
    <form method="post" action="search.asp">
    Search for <input name="fldSearch"> <input type="submit" value="Find me">
    <% if Request.Form("fldSearch")<>"" then
       strSearch=Request("fldSearch") %>
       <h5>. . . seeking a record from the Products Table where Product Name starts with "<%= strSearch %>" </h5>
       <% 'specify the provider
       strProvider="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("RenalDB.mdb")
       'create a recordset object
       set rsProds=Server.CreateObject("ADODB.Recordset")
       'set SQL Command
       strSQL="SELECT * FROM RenalData WHERE Drug LIKE '%" & strSearch & "%' ORDER BY DrugID"
       'open the RenalData recordset
       rsProds.Open "RenalData", strProvider, 1, 3, adCmdTable
       'find the record
       rsProds.Find ("Drug LIKE '" & strSearch & "%'") %>
       <table width="750">
       <!-- begin column headers for Products table -->
      <tr bgcolor="#8B99A0">
    <td align="center"><b>Drug</b> <br><br> $/Dose</td>
    <td align="center"><b>Usual Adult Dosage</b></td>
    <td align="center"><b>CreatCl (ml/min)</b></td>
    <td align="center"><b>Dosage Adjustment</b></td>
    <td align="center"><b>Hemodialyis Dose</b></td>
    <td align="center"><b>Ref</b></td>
       <% if not rsProds.EOF then 'display row results %>
       <tr valign="top" bgcolor="#EEF8FD">
    <td width="150"><b><%= rsProds ("DrugID")%></b> <b><%= rsProds ("Drug") %></b> <br><br> <%= rsProds ("$/Dose") %></td> 
    <td width="260"><%= rsProds ("Usual Adult Dosage") %>&nbsp;</td> 
    <td><%= rsProds ("ClCr (ml/min)") %>&nbsp;</td>
    <td width="200"><%= rsProds ("Dosage Adjustment") %>&nbsp;</td> 
    <td width="200"><%= rsProds ("Hemodialyis Dose") %>&nbsp;</td> 
    <td><%= rsProds ("Ref") %>&nbsp;</td> 
    <tr bgcolor="#005275">
    <td colspan="6"><a href="RenalPT_1.asp" class="link">Back</a></td>
       <% else %>
          <td colspan=6 align="center"><span class="head"><b>Sorry, no match found.</b></span></td></tr>
       <% end if %>
       <% 'close RenalData recset and flush from memory
       set rsProds = Nothing
    end if %>
    <% if not isEmpty(Request.Form) then %>
    <% end if %>
    Thank you.

  2. #2
    Join Date
    Dec 2004
    York, PA
    you need to loop through the recordset

    Do while Not rs.Eof
    'you display the record here
    Sorry to be terse
    some say it's a curse
    I know it's worse
    I'm just diverse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts