If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Restricted search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-01-05, 12:09
ph4ygo ph4ygo is offline
Registered User
 
Join Date: Feb 2005
Posts: 6
Question 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:
Code:
<form method="post" action="search.asp">
Search for <input name="fldSearch"> <input type="submit" value="Find me">
</form>

<% 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>
</tr>

   <% 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>
<tr bgcolor="#005275">
<td colspan="6"><a href="RenalPT_1.asp" class="link">Back</a></td>
</tr>
   <% else %>
      <td colspan=6 align="center"><span class="head"><b>Sorry, no match found.</b></span></td></tr>
   <% end if %>
   </table>
   <% 'close RenalData recset and flush from memory
   rsProds.Close
   set rsProds = Nothing
end if %>


<% if not isEmpty(Request.Form) then %>
  
<% end if %>
Thank you.
Reply With Quote
  #2 (permalink)  
Old 03-01-05, 14:03
White Knight White Knight is offline
Registered User
 
Join Date: Dec 2004
Location: York, PA
Posts: 95
you need to loop through the recordset

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On