[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Search page problems...

Posted on 2007-10-08
7
Medium Priority
?
265 Views
Last Modified: 2007-12-18
I am working on the following code for a search page that gets data from a database and displays it in a table on a seperate page. The problem I am having is, is that I cannot get the search to work with multiple search parameters that are entered on the form page. I am using an ODBC connection to a Interbase DB. All of these pages are written in ASP VbScript. Included is a portion of the existing code.

 Any help would be greatly appreciated!

Mark

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/SYSTECHDB.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "%"
If (Request.QueryString("desc1")  <> "") Then
  Recordset1__MMColParam = Request.QueryString("desc1")
End If
%>
<%
Dim Recordset1__MMColParam2
Recordset1__MMColParam2 = "%"
If (Request.QueryString("comp1")   <> "") Then
  Recordset1__MMColParam2 = Request.QueryString("comp1")  
End If
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 6
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_SYSTECHDB_STRING
Recordset1_cmd.CommandText = "SELECT MIX_ID, MIX_DESC, PROD_NBR, STRENGTH, MIX_COMP_NBR FROM MIXMASTER, MIXFORMULA WHERE MIX_DESC LIKE ? AND MIX_COMP_NBR LIKE ? ORDER BY PROD_NBR ASC"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 30, "%" + Recordset1__MMColParam + "%") ' adVarChar
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param2", 200, 1, 255, "%" + Recordset1__MMColParam2 + "%") ' adVarChar

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>

0
Comment
Question by:Mark Skrodzki
  • 5
  • 2
7 Comments
 
LVL 25

Accepted Solution

by:
kevp75 earned 2000 total points
ID: 20036968
are you coming up with an error?

try:
Recordset1_cmd.CommandText = "SELECT MIX_ID, MIX_DESC, PROD_NBR, STRENGTH, MIX_COMP_NBR FROM MIXMASTER, MIXFORMULA WHERE MIX_DESC LIKE %?% AND MIX_COMP_NBR LIKE %?% ORDER BY PROD_NBR ASC"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 30, Recordset1__MMColParam ) ' adVarChar
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param2", 200, 1, 255, Recordset1__MMColParam2 ) ' adVarChar
0
 
LVL 1

Author Comment

by:Mark Skrodzki
ID: 20037067
There isn't an error, I get records listed that don't match the search criteria. When data is entered into the first search box and submitted, I get records that do not match. THe second search entry box is empty. WHen I enter specific criteria in both boxes, I get records that match and do not match both criteria. I am wondering if and IF-THEN statement needs to be added??? Any suggestions?
0
 
LVL 1

Author Comment

by:Mark Skrodzki
ID: 20037129
If I remove the ability to search for text from the second text field and only do a search from the first entry field, it works great. THe problem is strictly with the addition of more than one search criteria. There is also the situation where the search is being done from two different tables, MIXMASTER and MIXFORMULA. Will the code I have currently work with the two tables?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 25

Expert Comment

by:kevp75
ID: 20037226
are the 2 tables related by a certain field?  If so, you should probably do a join:
http://www.w3schools.com/sql/sql_join.asp
0
 
LVL 1

Author Comment

by:Mark Skrodzki
ID: 20052168
That makes sense on the JOIN. Here is a confusing part, the form page only submits the field data to the results page. Then the results page does the database query. So, the URL sent to the results page will have data that is to be searched on from two tables. The DB query needs to be able to pull the data that matches only on the two pieces of data submitted from the form and nothing else. I know I am probably not telling you anything new. It's just confusing to me in a way.

I am using DreamWeaver 8 to write the pages so it uses it's own formating for the code which makes things a little more confusing. I will post the code from both pages for you to look at. On the second page (systechmixsearchresults1.asp), you can see how the DB query is coded. Does it make sense to you? I don't understand it very well as far as the CreateParameter line works. How can I add the ability to do the search on one or more of the data fields from the form? Maybe a sample of what the code would look like?
I would appreciate it greatly!!

Thank you, Mark.



SYSTECHMIXSEARCH.ASP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Systech Mix Design Search</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body class="sub">
<form action="systechmixsearchresults1.asp" method="get" name="mixsearch1" id="mixsearch1">
  <table width="90%" border="0" cellspacing="0" cellpadding="1" class="TitleColor">
    <tr>
      <td>
        <table width="100%" border="0" cellspacing="0" cellpadding="4">
          <tr class="HeaderColor">
            <td colspan="3">              <h3>Mix Design Search  </h3>            </td>
          </tr>
          <tr>
            <td style="text-align: right" class="TitleColor">              <label for="keywords">Description Keywords: </label>            </td>
            <td class="TitleColor">              <input size="50" id="keywords" name="desc1" value="" />            </td>
            <td rowspan="4" style="vertical-align: middle">
              <p>&nbsp;</p>
              <p>&nbsp;</p>              </td>
          </tr>
          <tr>
            <td style="text-align: right" class="TitleColor">              Component 1:            </td>
            <td class="TitleColor"><input name="comp1" type="text" id="comp1" size="50" /></td>
          </tr>
          <tr>
            <td style="text-align: right" class="TitleColor">
              <label for="select"> Component 2:</label>            </td>
            <td class="TitleColor"><input name="comp2" type="text" id="comp2" size="50" /></td>
          </tr>
          <tr>
            <td style="text-align: right" class="TitleColor">
            <label for="select"> Component 3:</label>            </td>
            <td class="TitleColor"><input name="comp3" type="text" id="comp3" size="50" /></td>
          </tr>
          <tr>
            <td style="text-align: right" class="TitleColor">
            <label for="select"> Component 4:</label>            </td>
            <td class="TitleColor"><input name="comp4" type="text" id="comp4" size="50" /></td>
            <td rowspan="8" style="vertical-align: middle">&nbsp;</td>
          </tr>
          <tr>
            <td style="text-align: right" class="TitleColor">
            <label for="select"> Component 5:</label>            </td>
            <td class="TitleColor"><input name="comp5" type="text" id="comp5" size="50" /></td>
          </tr>
          <tr>
            <td style="text-align: right" class="TitleColor">
            <label for="select"> Component 6:</label>            </td>
            <td class="TitleColor"><input name="comp6" type="text" id="comp6" size="50" /></td>
          </tr>
          <tr>
            <td style="text-align: right" class="TitleColor">
            <label for="select"> Component 7:</label>            </td>
            <td class="TitleColor"><input name="comp7" type="text" id="comp7" size="50" /></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="Submit" value="Go" /></td>
          </tr>
        </table>      </td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <table width="10%" border="0">
    <tr>
      <td><input type="button" name="Home" value="Home" onclick="window.location='protected.asp'"/></td>
      <td><input type="button" name="Back" value="Back" onclick="window.history.back(-1);"/></td>
    </tr>
  </table>
  <p></p>
  <p>&nbsp;</p>
</form>
</body>
</html>

SYSTECHMIXSEARCHRESULTS1.ASP

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/SYSTECHDB.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "%"
If (Request.QueryString("desc1")  <> "") Then
  Recordset1__MMColParam = Request.QueryString("desc1")
End If
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 6
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_SYSTECHDB_STRING
Recordset1_cmd.CommandText = "SELECT * FROM MIXMASTER WHERE MIX_DESC LIKE ?  ORDER BY PROD_NBR ASC"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 30, "%" + Recordset1__MMColParam + "%") ' adVarChar

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<%
'  *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

Dim Recordset1_total
Dim Recordset1_first
Dim Recordset1_last

' set the record count
Recordset1_total = Recordset1.RecordCount

' set the number of rows displayed on this page
If (Recordset1_numRows < 0) Then
  Recordset1_numRows = Recordset1_total
Elseif (Recordset1_numRows = 0) Then
  Recordset1_numRows = 1
End If

' set the first and last displayed record
Recordset1_first = 1
Recordset1_last  = Recordset1_first + Recordset1_numRows - 1

' if we have the correct record count, check the other stats
If (Recordset1_total <> -1) Then
  If (Recordset1_first > Recordset1_total) Then
    Recordset1_first = Recordset1_total
  End If
  If (Recordset1_last > Recordset1_total) Then
    Recordset1_last = Recordset1_total
  End If
  If (Recordset1_numRows > Recordset1_total) Then
    Recordset1_numRows = Recordset1_total
  End If
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them

If (Recordset1_total = -1) Then

  ' count the total records by iterating through the recordset
  Recordset1_total=0
  While (Not Recordset1.EOF)
    Recordset1_total = Recordset1_total + 1
    Recordset1.MoveNext
  Wend

  ' reset the cursor to the beginning
  If (Recordset1.CursorType > 0) Then
    Recordset1.MoveFirst
  Else
    Recordset1.Requery
  End If

  ' set the number of rows displayed on this page
  If (Recordset1_numRows < 0 Or Recordset1_numRows > Recordset1_total) Then
    Recordset1_numRows = Recordset1_total
  End If

  ' set the first and last displayed record
  Recordset1_first = 1
  Recordset1_last = Recordset1_first + Recordset1_numRows - 1
 
  If (Recordset1_first > Recordset1_total) Then
    Recordset1_first = Recordset1_total
  End If
  If (Recordset1_last > Recordset1_total) Then
    Recordset1_last = Recordset1_total
  End If

End If
%>
<%
Dim MM_paramName
%>
<%
' *** Move To Record and Go To Record: declare variables

Dim MM_rs
Dim MM_rsCount
Dim MM_size
Dim MM_uniqueCol
Dim MM_offset
Dim MM_atTotal
Dim MM_paramIsDefined

Dim MM_param
Dim MM_index

Set MM_rs    = Recordset1
MM_rsCount   = Recordset1_total
MM_size      = Recordset1_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
  MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Record: handle 'index' or 'offset' parameter

if (Not MM_paramIsDefined And MM_rsCount <> 0) then

  ' use index parameter if defined, otherwise use offset parameter
  MM_param = Request.QueryString("index")
  If (MM_param = "") Then
    MM_param = Request.QueryString("offset")
  End If
  If (MM_param <> "") Then
    MM_offset = Int(MM_param)
  End If

  ' if we have a record count, check if we are past the end of the recordset
  If (MM_rsCount <> -1) Then
    If (MM_offset >= MM_rsCount Or MM_offset = -1) Then  ' past end or move last
      If ((MM_rsCount Mod MM_size) > 0) Then         ' last page not a full repeat region
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  ' move the cursor to the selected record
  MM_index = 0
  While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend
  If (MM_rs.EOF) Then
    MM_offset = MM_index  ' set MM_offset to the last possible record
  End If

End If
%>
<%
' *** Move To Record: if we dont know the record count, check the display range

If (MM_rsCount = -1) Then

  ' walk to the end of the display range for this page
  MM_index = MM_offset
  While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend

  ' if we walked off the end of the recordset, set MM_rsCount and MM_size
  If (MM_rs.EOF) Then
    MM_rsCount = MM_index
    If (MM_size < 0 Or MM_size > MM_rsCount) Then
      MM_size = MM_rsCount
    End If
  End If

  ' if we walked off the end, set the offset based on page size
  If (MM_rs.EOF And Not MM_paramIsDefined) Then
    If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
      If ((MM_rsCount Mod MM_size) > 0) Then
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  ' reset the cursor to the beginning
  If (MM_rs.CursorType > 0) Then
    MM_rs.MoveFirst
  Else
    MM_rs.Requery
  End If

  ' move the cursor to the selected record
  MM_index = 0
  While (Not MM_rs.EOF And MM_index < MM_offset)
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend
End If
%>
<%
' *** Move To Record: update recordset stats

' set the first and last displayed record
Recordset1_first = MM_offset + 1
Recordset1_last  = MM_offset + MM_size

If (MM_rsCount <> -1) Then
  If (Recordset1_first > MM_rsCount) Then
    Recordset1_first = MM_rsCount
  End If
  If (Recordset1_last > MM_rsCount) Then
    Recordset1_last = MM_rsCount
  End If
End If

' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth

Dim MM_removeList
Dim MM_item
Dim MM_nextItem

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
  MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If

MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
  End If
Next

' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
  End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
  MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "")  Then
  MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
  MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
  If (firstItem <> "") Then
    MM_joinChar = "&"
  Else
    MM_joinChar = ""
  End If
End Function
%>
<%
' *** Move To Record: set the strings for the first, last, next, and previous links

Dim MM_keepMove
Dim MM_moveParam
Dim MM_moveFirst
Dim MM_moveLast
Dim MM_moveNext
Dim MM_movePrev

Dim MM_urlStr
Dim MM_paramList
Dim MM_paramIndex
Dim MM_nextParam

MM_keepMove = MM_keepBoth
MM_moveParam = "index"

' if the page has a repeated region, remove 'offset' from the maintained parameters
If (MM_size > 1) Then
  MM_moveParam = "offset"
  If (MM_keepMove <> "") Then
    MM_paramList = Split(MM_keepMove, "&")
    MM_keepMove = ""
    For MM_paramIndex = 0 To UBound(MM_paramList)
      MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)
      If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then
        MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)
      End If
    Next
    If (MM_keepMove <> "") Then
      MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
    End If
  End If
End If

' set the strings for the move to links
If (MM_keepMove <> "") Then
  MM_keepMove = Server.HTMLEncode(MM_keepMove) & "&"
End If

MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="

MM_moveFirst = MM_urlStr & "0"
MM_moveLast  = MM_urlStr & "-1"
MM_moveNext  = MM_urlStr & CStr(MM_offset + MM_size)
If (MM_offset - MM_size < 0) Then
  MM_movePrev = MM_urlStr & "0"
Else
  MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body class="sub">
<table width="90%" border="0" cellspacing="2" cellpadding="4">
  <tr>
    <td style="text-align: center" class="HeaderColor"> Result Pages <%=(Recordset1_first)%> - <%=(Recordset1_last)%> of <%=(Recordset1_total)%>
        <% If MM_offset <> 0 Then %>
  &nbsp;&nbsp;|&nbsp;&nbsp;<A HREF="<%=MM_movePrev%>">&lt;&lt; Previous Page</A>
  <% End If ' end MM_offset <> 0 %>
        <% If Not MM_atTotal Then %>
          <a HREF="<%=MM_moveNext%>"> Next Page &gt;&gt;</a>
          <% End If ' end Not MM_atTotal %>
</td>
  </tr>
</table>

<table width="90%" border="0" cellspacing="2" cellpadding="4">
  <%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
    <tr>
      <td height="31">      <strong>Mix Number: </strong>    </td>
      <td width="712">      <strong><A HREF="mixformuladetail.asp?<%= Server.HTMLEncode(MM_keepURL) & MM_joinChar(MM_keepURL) & "MIX_ID=" & Recordset1.Fields.Item("MIX_ID").Value %>"><%=(Recordset1.Fields.Item("PROD_NBR").Value)%></a></A></strong>    </td>
    </tr>
    <tr>
      <td width="93" height="30
        ">&nbsp;    </td>
      <td>
        <p class="StoryContentColor"><%=(Recordset1.Fields.Item("MIX_DESC").Value)%></p>        </td>
    </tr>
    <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%>
</table>
<p>&nbsp;</p>
<table width="90%" border="0" cellspacing="2" cellpadding="4">
  <tr>
    <td style="text-align: center" class="FooterColor"><span class="HeaderColor" style="text-align: center">Result Pages<%=(Recordset1_first)%> - <%=(Recordset1_last)%> of <%=(Recordset1_total)%>&nbsp;</span>&nbsp;&nbsp;|&nbsp;&nbsp;
      <% If MM_offset <> 0 Then %>
        <A HREF="<%=MM_movePrev%>">&lt;&lt; Previous Page</A>
        <% End If ' end MM_offset <> 0 %>
      <% If Not MM_atTotal Then %>
        <a HREF="<%=MM_moveNext%>">Next Page &gt;&gt;</a>
    <% End If ' end Not MM_atTotal %></td>
  </tr>
</table>
<table width="90%" border="0" cellspacing="2" cellpadding="4">

</table>
<table width="10%" border="0">
  <tr>
    <td><input type="button" name="Home" value="Home" onClick="window.location='protected.asp'"/></td>
    <td><input type="button" name="Back" value="Back" onClick="window.history.back(-1);"/></td>
  </tr>
</table>
<p class="NavigationColor">&nbsp;</p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>


0
 
LVL 1

Author Comment

by:Mark Skrodzki
ID: 20352373
Sorry for the long delay on this issue. I have found that the data in the DB is very dis-organized. The data I was working on is inconsistant and gives eronious results. I am working with the vendor of the original app and DB to help me figure it out. From here on, I am not sure how to procede with this question? There isn't a solution because the question is no longer relevant. Not sure if I am going to proceding with this issue further. Please advise...
0
 
LVL 1

Author Comment

by:Mark Skrodzki
ID: 20496182
Here is the working code. Thanks for the help!
<!--#include file="Connections/WOT.asp" -->
<% Response.Buffer = True %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Parts Search Page</title>
</head>
 
<body>
<%
Dim rs1
Dim rs1_cmd
Dim rs1_numRows
 
Set rs1_cmd = Server.CreateObject ("ADODB.Command")
rs1_cmd.ActiveConnection = MM_WOT_STRING
rs1_cmd.CommandText = "SELECT * FROM wot.inv" 
rs1_cmd.Prepared = true
 
Set rs1 = rs1_cmd.Execute
rs1_numRows = 0
'desc=request.form("partdesc")
'partnum=request.form("partnum")
'vendor=request.form("vendor")
%>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="">
  <table width="50%" border="0" cellspacing="0" cellpadding="1">
    <tr>
      <td><div align="right">Description:</div></td>
      <td><input name="partdesc" type="text" id="partdesc" size="50" /></td>
    </tr>
    <tr>
      <td><div align="right">Part Number: </div></td>
      <td><input name="partnum" type="text" id="partnum" size="50" /></td>
    </tr>
    <tr>
      <td><div align="right">Vendor:</div></td>
      <td><input name="vendor" type="text" id="vendor" size="50" /></td>
    </tr>
    <tr>
      <td><div align="right">Manufacturer</div></td>
      <td><input name="manufacturer" type="text" id="manufacturer" size="50" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><div align="right">
        <input name="search" type="submit" id="search" value="Search" />
      </div></td>
    </tr>
  </table>
<%
rs1.Close()
Set rs1 = Nothing
%>  
</form>
<table width="100%" border="0" cellspacing="0" cellpadding="1" >
  <tr bgcolor="#FFCC00">
    <th width="16%"><div align="left">Part Number </div></th>
    <th width="44%"><div align="left">Description</div></th>
    <th width="20%"><div align="left">Vendor</div></th>
    <th width="20%"><div align="left">Manufacturer</div></th>
  </tr>
 
<%
if request.form("search")="Search" then
	Dim rs2
	Dim rs2_cmd
	Dim rs2_numRows
	Dim sql
	'sql="SELECT * FROM wot.inv "
	sql="SELECT * FROM wot.inv WHERE "
	Set rs2_cmd = Server.CreateObject ("ADODB.Command")
	rs2_cmd.ActiveConnection = MM_WOT_STRING
	
	If request.form("partdesc") <> "" Then sql= sql & " partdesc LIKE '%" + request.form("partdesc")+ "%'and "
	If request.form("partnum") <> "" Then sql= sql & " partnum LIKE '%" + request.form("partnum")+ "%'and "
	If request.form("vendor") <> "" Then sql= sql & " vendor LIKE '%" + request.form("vendor")+ "%'and "
	If request.form("manufacturer") <> "" Then sql= sql & " manufacturer LIKE '%" + request.form("manufacturer")+ "%'and "
	sql=sql & "1=1"
	'If request.form("partdesc") <> "" Then WhereClause= "or partdesc LIKE '%" + request.form("partdesc")+ "%'"
	'If request.form("partnum") <> "" Then WhereClause= "or partnum LIKE '%" + request.form("partnum")+ "%'"
	'If request.form("vendor") <> "" Then WhereClause= "or vendor LIKE '%" + request.form("vendor")+ "%'"
	'If WhereClause <> "" Then
		'WhereClause = "WHERE " & Mid(WhereClause,4)'Strip off the 1st 'or'
	'End If
	'rs2_cmd.CommandText = sql & WhereClause
	rs2_cmd.CommandText = sql
	'End If
	rs2_cmd.Prepared = true
	
'response.write(rs2_cmd.CommandText)	
 
	Set rs2 = rs2_cmd.Execute
	rs2_numRows = 0
 
%>
<%
Dpartnum=rs2.fields.item("partnum")
Dselection="<a href=addparts2.asp?partnum=" & rs2.fields.item("ID") & ">SELECT</a>"
%>
<%
do until rs2.EOF
	response.write("<tr>")
	response.write("<td>") & "<a href=addparts2.asp?partnumid=" & rs2.fields.item("ID") & ">"& rs2.fields.item("partnum") &"</a>" & ("</td>")
	'response.write("<td>" & rs2.fields("partnum") & "</td>")
	response.write("<td>" & rs2.fields.item("partdesc") & "</td>")
	response.write("<td>" & rs2.fields.item("vendor") & "</td>")
	response.write("<td>" & rs2.fields.item("manufacturer") & "</td>")
	'response.write("<td>") & "<a href=addparts.asp?partnumid=" & rs2.fields.item("ID") & ">SELECT</a>" & ("</td>")
	'response.write("<td>" & Dselection & "</td>") 
	response.write("</tr>")
	rs2.MoveNext
loop
'response.write(Dpartnum)
 
rs2.Close()
Set rs2 = Nothing
%>
</table>
<% end if %>
<p>&nbsp;
<%'response.write(request.form("desc"))%>
</p>
  <input name="btnBack" type="button" onClick="window.location='addparts2.asp?<%= "ID=" & Session("WOID") %>'" value="Back to Add Parts Page"/>
</body>
</html>

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month17 days, 14 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question