Searching a Database ASP/HTML Problem

  • cmac
  • Novice
  • Novice
  • cmac
  • Posts: 27
  • Loc: TX

Post 3+ Months Ago

I'm trying to write a webpage using asp and html that searches an access database and displays the results. I'm using dreamweaver to write the code and having no luck with the debugger. When I upload the page to my server I get "HTTP 500 Internal Server Error" so I know that the page is there, there is just an error in the code. The end result will look similar to this, http://www.studiosevensystems.com/original_surplus/sample.asp, just with a few of the fields changed and some removed. I know that this is a lot of code and the error is probably very obvious but can anyone who is bored at work (like me) figure out why this isn't working. any help is appreciated.


Code: [ Select ]
<%@ Language=VBScript %>
<!-- METADATA TYPE="typelib" UUID="00000200-0000-0010-8000-00AA006D2EA4" NAME="ADO Type Library"-->

<%
Option Explicit
Response.Buffer = True        'Turn buffering on
Response.Expires = -1        'Page expires immediately

'Constants
Const MIN_PAGESIZE = 5        'Minimum pagesize
Const MAX_PAGESIZE = 20        'Maximum pagesize
Const DEF_PAGESIZE = 10        'Default pagesize

'Variables
Dim objCn                    'ADO DB connection object
Dim objRs                    'ADO DB recordset object
Dim blnWhere                'True/False for have WHERE in sql already
Dim intRecord                'Current record for paging recordset
Dim intPage                    'Requested page
Dim intPageSize                'Requested pagesize
Dim sql                        'Dynamic sql query string

'Create objects
Set objCn = Server.CreateObject("ADODB.Connection")
Set objRs = Server.CreateObject("ADODB.Recordset")

'Set/initialize variables
intRecord = 1
blnWhere = False

'-Get/set requested page
intPage = MakeLong(Request("page"))
If intPage < 1 Then intPage = 1

'-Get/set requested pagesize
If IsEmpty(Request("pagesize")) Then    'Set to default
    intPageSize = DEF_PAGESIZE
Else
    intPageSize = MakeLong(Request("pagesize"))
    'Make sure it fits our min/max requirements    
    If intPageSize < MIN_PAGESIZE Then
        intPageSize = MIN_PAGESIZE
    ElseIf intPageSize > MAX_PAGESIZE Then
        intPageSize = MAX_PAGESIZE
    End If
End If

'-Build dynamic sql
sql = "SELECT Category, Subcategory, Description FROM SURPLUS DB"

'--category (exact search only)
If Not IsEmpty(Request("Category")) Then
    If IsNumeric(Request("Category")) Then
        'Add to query
        'First item so we don't have to test for WHERE
        blnWhere = True 'Set where to true
        sql = sql & "WHERE "
        sql = sql & "(Category = " & CStr(CLng(Request("Category"))) & ") "
    End If
End If

'--Subcategory (partial and exact search)
If Not IsEmpty(Request("Subcategory")) Then
    Dim strSubcategory
    strSubcategory = Trim(Request("Subcategory"))
    
    If strSubcategory <> "" Then
        'Test for WHERE
        If blnWhere Then sql = sql & "AND " Else sql = sql & "WHERE " : blnWhere = True
        
        If (Left(strSubcategory, 1) = "*" And Len(strSubcategory) > 1) Then    'Partial search
            sql = sql & "(Subcategory LIKE '%" & Replace(Mid(strSubcategory, 2), "'", "''") & "') "    
        ElseIf (Right(strsubcategory, 1) = "*" And Len(strSubcategory) > 1) Then    'Partial search
            sql = sql & "(Subcategory LIKE '" & Replace(Mid(strSubcategory, 1, Len(strSubcategory)-1), "'", "''") & "%') "    
        Else    'Exact match
            sql = sql & "(Subcategory = '" & Replace(strSubcategory, "'", "''") & "') "
        End If

    End If
End If

'--Description (parital search only)
If Not IsEmpty(Request("Description")) Then
    Dim strDescription
    strDescription = Trim(Request("Description"))
    
    If strDescription <> "" Then
        'Test for WHERE
        If blnWhere Then sql = sql & "AND " Else sql = sql & "WHERE " : blnWhere = True
        sql = sql & "(Description LIKE '%" & Replace(strDescription, "'", "''") & "%') "
    End If
End If

'--Sort By Field
sql = sql & "ORDER BY "
Select Case Trim(LCase(Request("sortby")))
    Case "Subcategory":            sql = sql & "Subcategory "
    Case "Description":      sql = sql & "Description "
    Case Else:            sql = sql & "Category "
End Select

'--Sort Order
Select Case Trim(LCase(Request("sortorder")))
    Case "desc":    sql = sql & "DESC"
    Case Else:        sql = sql & "ASC"
End Select
'--Dynamic sql finished

'Create and open connection object
With objCn
    .CursorLocation = adUseClient
    .ConnectionTimeout = 15
    .CommandTimeout = 30
    .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                        "Data Source=" & Server.MapPath("Database File Path Goes Here") & ";"
    .Open
End With

'Create and open recordset object
With objRs
    .ActiveConnection = objCn
    .CursorLocation = adUseClient
    .CursorType = adOpenForwardOnly
    .LockType = adLockReadOnly
    .Source = sql
    .PageSize = intPageSize
    .Open
    Set .ActiveConnection = Nothing    'Disconnect the recordset
End With

'Creates a long value from a variant, invalid always set to zero
Function MakeLong(ByVal varValue)
    If IsNumeric(varValue) Then
        MakeLong = CLng(varValue)
    Else
        MakeLong = 0
    End If
End Function

'Returns a neatly made paging string, automatically configuring for request
'variables, regardless of in querystring or from form, adjust output to your needs.
Function Paging(ByVal intPage, ByVal intPageCount, ByVal intRecordCount)
    Dim strQueryString
    Dim strScript
    Dim intStart
    Dim intEnd
    Dim strRet
    Dim i

    If intPage > intPageCount Then
        intPage = intPageCount
    ElseIf intPage < 1 Then
        intPage = 1
    End If
    
    If intRecordCount = 0 Then
        strRet = "No Records Found"
    ElseIf intPageCount = 1 Then
        strRet = "End Of Hits"
    Else
        For i = 1 To Request.QueryString.Count
            If LCase(Request.QueryString.Key(i)) <> "page" Then
                strQueryString = strQueryString & "&"
                strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Key(i)) & "="
                strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Item(i))
            End If
        Next

        For i = 1 To Request.Form.Count
            If LCase(Request.Form.Key(i)) <> "page" Then
                strQueryString = strQueryString & "&"
                strQueryString = strQueryString & Server.URLEncode(Request.Form.Key(i)) & "="
                strQueryString = strQueryString & Server.URLEncode(Request.Form.Item(i))
            End If
        Next

        If Len(strQueryString) <> 0 Then
            strQueryString = "?" & Mid(strQueryString, 2) & "&"
        Else
            strQueryString = "?"
        End If

        strScript = Request.ServerVariables("SCRIPT_NAME") & strQueryString
    
        If intPage <= 10 Then
            intStart = 1
        Else
            If (intPage Mod 10) = 0 Then
                intStart = intPage - 9
            Else
                intStart = intPage - (intPage Mod 10) + 1
            End If
        End If

        intEnd = intStart + 9
        If intEnd > intPageCount Then intEnd = intPageCount
    
        strRet = "Page " & intPage & " of " & intPageCount & ": "
    
        If intPage <> 1 Then
            strRet = strRet & "<a href=""" & strScript
            strRet = strRet & "page=" & intPage - 1
            strRet = strRet & """>&lt;&lt;Prev</a> "
        End If
    
        For i = intStart To intEnd
            If i = intPage Then
                strRet = strRet & "<b>" & i & "</b> "
            Else
                strRet = strRet & "<a href=""" & strScript
                strRet = strRet & "page=" & i
                strRet = strRet & """>" & i & "</a>"
                If i <> intEnd Then strRet = strRet & " "
            End If
        Next
    
        If intPage <> intPageCount Then
            strRet = strRet & " <a href=""" & strScript
            strRet = strRet & "page=" & intPage + 1
            strRet = strRet & """>Next&gt;&gt;</a> "
        End If
    End If
    
    Paging = strRet
End Function
%>


<html>
<head>
<title>Surplus</title>
<style>
BODY
{
  FONT-WEIGHT: normal;
  FONT-SIZE: 9pt;
  COLOR: black;
  FONT-FAMILY: Arial, Helvetica, sans-serif;
  TEXT-DECORATION: none
}
TABLE
{
  FONT-WEIGHT: normal;
  FONT-SIZE: 9pt;
  COLOR: black;
  FONT-FAMILY: Arial, Helvetica, sans-serif;
  TEXT-DECORATION: none
}
A
{
  FONT-WEIGHT: normal;
  FONT-SIZE: 9pt;
  COLOR: blue;
  FONT-FAMILY: Arial, Helvetica, sans-serif;
  TEXT-DECORATION: underline
}
HR
{
  COLOR: #0072bc
}
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
 if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body onload="javascript: document.frmSearch.category.select();">

<table border="0" width="100%" cellpadding="2" cellspacing="2">
 <tr>
  <td align=center><h3>Surplus Search</h3></td>
 </tr>
 <tr>
  <td><hr></td>
 </tr>
 <!--Search Form-->
 <form name="frmSearch" method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
  <input type="hidden" name="page" value="1">
  <tr>
   <td align=center> <table border="0" width="100%" cellpadding="2" cellspacing="2">
     <tr>
      <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Search
       by Category</font></td>
     </tr>
     <tr>
      <td nowrap><b>Category</b></td>
      <td width="100%"><input type="text" name="category" value="<%=Server.HTMLEncode(Request("Category"))%>" size="10">
        </td>
     </tr>
     <tr>
      <td height="27" nowrap><b>Subcategory</b></td>
      <td width="100%"><input type="text" name="subcategory" size="20" value="<%=Server.HTMLEncode(Request("Subcategory"))%>">
      </td>
     </tr>
     <tr>
      <td height="19" colspan="2"><strong> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OR</strong></td>
     </tr>
     <tr>
      <td height="19" colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Search
       by Description</font></td>
     </tr>
     <tr>
      <td nowrap><b>Description:</b></td>
      <td><input type="text" name="description" size="20" value="<%=Server.HTMLEncode(Request("Description"))%>">
       &nbsp;<font size="-2">(partial match)</font></td>
     </tr>
     <tr>
      <td nowrap><b>Sort By:</b></td>
      <td> <select name="sortby">
        <option value="Category">Product category</option>
        <option value="Subcategory"<%If Trim(LCase(Request("sortby"))) = "Subcategory" Then Response.Write " selected"%>>Product
        subcategory</option>
        <option value="Description"<%If Trim(LCase(Request("sortby"))) = "Description" Then Response.Write " selected"%>>Description</option>
       </select>
       &nbsp;
       <select name="sortorder">
        <option value="asc">Ascending</option>
        <option value="desc"<%If Trim(LCase(Request("sortorder"))) = "desc" Then Response.Write " selected"%>>Descending</option>
       </select> </td>
     </tr>
     <tr>
      <td nowrap><b>Records Per Page:</b></td>
      <td><input type="text" name="pagesize" size="10" value="<%=intPageSize%>"></td>
     </tr>
     <tr>
      <td colspan="2"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       <input type="submit" name="btnSubmit" value="Go!"> &nbsp; &nbsp;
       <input type="button" name="btnRestart" value="Reset" onClick="javascript: window.location='<%=Request.ServerVariables("SCRIPT_NAME")%>'">
       &nbsp; &nbsp; </td>
     </tr>
     <tr>
      <td height="19" colspan="2">&nbsp;</td>
     </tr>
    </table></td>
  </tr>
 </form>
 <tr>
  <td><hr align="center"></td>
 </tr>
 <%If objRs.EOF Then%>
 <!--No Records Found-->
 <tr>
  <td align="center"><b><font size="4">No products found!</font></b></td>
 </tr>
 <%Else%>
 <!--Records Found-->
 <tr>
  <td> <table width="51%" border="0" align="center" cellpadding="3" cellspacing="3">
    <tr>
     <td colspan=4><b>Items Found: </b><%=objRs.RecordCount%></td>
    </tr>
    <tr>
     <td align="center" colspan="4"><%=Paging(intPage, objRs.PageCount, objRs.RecordCount)%></td>
    </tr>
    <tr bgcolor="#efefef">
     <td nowrap><b>Category</b></td>
     <td nowrap><b>Subcategory</b></td>
     <td nowrap width="100%"><b>Description</b></td>
     </tr>
    <%
                If objRs.PageCount < intPage Then intPage = objRs.PageCount
                objRs.AbsolutePage = intPage
                
                Dim strRowColor
                strRowColor = "#ffffff"
                
                Do While Not objRs.EOF And intRecord <= intPageSize
                    %>
    <tr bgcolor="<%=strRowColor%>">
     <td nowrap><%=objRs("Category").Value%></td>
     <td nowrap><%=objRs("Subcategory").Value%></td>
     <td><%=objRs("Description").Value%></td>
    </tr>
    <%
                    If strRowColor = "#ffffff" Then strRowColor = "#CCCCCC" Else strRowColor = "#ffffff"
                    intRecord = intRecord + 1
                    objRs.MoveNext
                Loop
                %>
    <tr>
     <td colspan="4"><hr></td>
    </tr>
    <tr>
     <td align="center" colspan="4"><%=Paging(intPage, objRs.PageCount, objRs.RecordCount)%></td>
    </tr>
   </table></td>
 </tr>
 <tr>
  <td><hr></td>
 </tr><br>
 <tr><td></td></tr>
 <%End If%>
</table>
</body>
</html>

<%
'Object cleanup
If IsObject(objRs) Then
    If Not objRs Is Nothing Then
        If objRs.State = adStateOpen Then objRs.Close
        Set objRs = Nothing
    End If
End If

If IsObject(objCn) Then
    If Not objCn Is Nothing Then
        If objCn.State = adStateOpen Then objCn.Close
        Set objCn = Nothing
    End If
End If
%>
  1. <%@ Language=VBScript %>
  2. <!-- METADATA TYPE="typelib" UUID="00000200-0000-0010-8000-00AA006D2EA4" NAME="ADO Type Library"-->
  3. <%
  4. Option Explicit
  5. Response.Buffer = True        'Turn buffering on
  6. Response.Expires = -1        'Page expires immediately
  7. 'Constants
  8. Const MIN_PAGESIZE = 5        'Minimum pagesize
  9. Const MAX_PAGESIZE = 20        'Maximum pagesize
  10. Const DEF_PAGESIZE = 10        'Default pagesize
  11. 'Variables
  12. Dim objCn                    'ADO DB connection object
  13. Dim objRs                    'ADO DB recordset object
  14. Dim blnWhere                'True/False for have WHERE in sql already
  15. Dim intRecord                'Current record for paging recordset
  16. Dim intPage                    'Requested page
  17. Dim intPageSize                'Requested pagesize
  18. Dim sql                        'Dynamic sql query string
  19. 'Create objects
  20. Set objCn = Server.CreateObject("ADODB.Connection")
  21. Set objRs = Server.CreateObject("ADODB.Recordset")
  22. 'Set/initialize variables
  23. intRecord = 1
  24. blnWhere = False
  25. '-Get/set requested page
  26. intPage = MakeLong(Request("page"))
  27. If intPage < 1 Then intPage = 1
  28. '-Get/set requested pagesize
  29. If IsEmpty(Request("pagesize")) Then    'Set to default
  30.     intPageSize = DEF_PAGESIZE
  31. Else
  32.     intPageSize = MakeLong(Request("pagesize"))
  33.     'Make sure it fits our min/max requirements    
  34.     If intPageSize < MIN_PAGESIZE Then
  35.         intPageSize = MIN_PAGESIZE
  36.     ElseIf intPageSize > MAX_PAGESIZE Then
  37.         intPageSize = MAX_PAGESIZE
  38.     End If
  39. End If
  40. '-Build dynamic sql
  41. sql = "SELECT Category, Subcategory, Description FROM SURPLUS DB"
  42. '--category (exact search only)
  43. If Not IsEmpty(Request("Category")) Then
  44.     If IsNumeric(Request("Category")) Then
  45.         'Add to query
  46.         'First item so we don't have to test for WHERE
  47.         blnWhere = True 'Set where to true
  48.         sql = sql & "WHERE "
  49.         sql = sql & "(Category = " & CStr(CLng(Request("Category"))) & ") "
  50.     End If
  51. End If
  52. '--Subcategory (partial and exact search)
  53. If Not IsEmpty(Request("Subcategory")) Then
  54.     Dim strSubcategory
  55.     strSubcategory = Trim(Request("Subcategory"))
  56.     
  57.     If strSubcategory <> "" Then
  58.         'Test for WHERE
  59.         If blnWhere Then sql = sql & "AND " Else sql = sql & "WHERE " : blnWhere = True
  60.         
  61.         If (Left(strSubcategory, 1) = "*" And Len(strSubcategory) > 1) Then    'Partial search
  62.             sql = sql & "(Subcategory LIKE '%" & Replace(Mid(strSubcategory, 2), "'", "''") & "') "    
  63.         ElseIf (Right(strsubcategory, 1) = "*" And Len(strSubcategory) > 1) Then    'Partial search
  64.             sql = sql & "(Subcategory LIKE '" & Replace(Mid(strSubcategory, 1, Len(strSubcategory)-1), "'", "''") & "%') "    
  65.         Else    'Exact match
  66.             sql = sql & "(Subcategory = '" & Replace(strSubcategory, "'", "''") & "') "
  67.         End If
  68.     End If
  69. End If
  70. '--Description (parital search only)
  71. If Not IsEmpty(Request("Description")) Then
  72.     Dim strDescription
  73.     strDescription = Trim(Request("Description"))
  74.     
  75.     If strDescription <> "" Then
  76.         'Test for WHERE
  77.         If blnWhere Then sql = sql & "AND " Else sql = sql & "WHERE " : blnWhere = True
  78.         sql = sql & "(Description LIKE '%" & Replace(strDescription, "'", "''") & "%') "
  79.     End If
  80. End If
  81. '--Sort By Field
  82. sql = sql & "ORDER BY "
  83. Select Case Trim(LCase(Request("sortby")))
  84.     Case "Subcategory":            sql = sql & "Subcategory "
  85.     Case "Description":      sql = sql & "Description "
  86.     Case Else:            sql = sql & "Category "
  87. End Select
  88. '--Sort Order
  89. Select Case Trim(LCase(Request("sortorder")))
  90.     Case "desc":    sql = sql & "DESC"
  91.     Case Else:        sql = sql & "ASC"
  92. End Select
  93. '--Dynamic sql finished
  94. 'Create and open connection object
  95. With objCn
  96.     .CursorLocation = adUseClient
  97.     .ConnectionTimeout = 15
  98.     .CommandTimeout = 30
  99.     .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  100.                         "Data Source=" & Server.MapPath("Database File Path Goes Here") & ";"
  101.     .Open
  102. End With
  103. 'Create and open recordset object
  104. With objRs
  105.     .ActiveConnection = objCn
  106.     .CursorLocation = adUseClient
  107.     .CursorType = adOpenForwardOnly
  108.     .LockType = adLockReadOnly
  109.     .Source = sql
  110.     .PageSize = intPageSize
  111.     .Open
  112.     Set .ActiveConnection = Nothing    'Disconnect the recordset
  113. End With
  114. 'Creates a long value from a variant, invalid always set to zero
  115. Function MakeLong(ByVal varValue)
  116.     If IsNumeric(varValue) Then
  117.         MakeLong = CLng(varValue)
  118.     Else
  119.         MakeLong = 0
  120.     End If
  121. End Function
  122. 'Returns a neatly made paging string, automatically configuring for request
  123. 'variables, regardless of in querystring or from form, adjust output to your needs.
  124. Function Paging(ByVal intPage, ByVal intPageCount, ByVal intRecordCount)
  125.     Dim strQueryString
  126.     Dim strScript
  127.     Dim intStart
  128.     Dim intEnd
  129.     Dim strRet
  130.     Dim i
  131.     If intPage > intPageCount Then
  132.         intPage = intPageCount
  133.     ElseIf intPage < 1 Then
  134.         intPage = 1
  135.     End If
  136.     
  137.     If intRecordCount = 0 Then
  138.         strRet = "No Records Found"
  139.     ElseIf intPageCount = 1 Then
  140.         strRet = "End Of Hits"
  141.     Else
  142.         For i = 1 To Request.QueryString.Count
  143.             If LCase(Request.QueryString.Key(i)) <> "page" Then
  144.                 strQueryString = strQueryString & "&"
  145.                 strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Key(i)) & "="
  146.                 strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Item(i))
  147.             End If
  148.         Next
  149.         For i = 1 To Request.Form.Count
  150.             If LCase(Request.Form.Key(i)) <> "page" Then
  151.                 strQueryString = strQueryString & "&"
  152.                 strQueryString = strQueryString & Server.URLEncode(Request.Form.Key(i)) & "="
  153.                 strQueryString = strQueryString & Server.URLEncode(Request.Form.Item(i))
  154.             End If
  155.         Next
  156.         If Len(strQueryString) <> 0 Then
  157.             strQueryString = "?" & Mid(strQueryString, 2) & "&"
  158.         Else
  159.             strQueryString = "?"
  160.         End If
  161.         strScript = Request.ServerVariables("SCRIPT_NAME") & strQueryString
  162.     
  163.         If intPage <= 10 Then
  164.             intStart = 1
  165.         Else
  166.             If (intPage Mod 10) = 0 Then
  167.                 intStart = intPage - 9
  168.             Else
  169.                 intStart = intPage - (intPage Mod 10) + 1
  170.             End If
  171.         End If
  172.         intEnd = intStart + 9
  173.         If intEnd > intPageCount Then intEnd = intPageCount
  174.     
  175.         strRet = "Page " & intPage & " of " & intPageCount & ": "
  176.     
  177.         If intPage <> 1 Then
  178.             strRet = strRet & "<a href=""" & strScript
  179.             strRet = strRet & "page=" & intPage - 1
  180.             strRet = strRet & """>&lt;&lt;Prev</a> "
  181.         End If
  182.     
  183.         For i = intStart To intEnd
  184.             If i = intPage Then
  185.                 strRet = strRet & "<b>" & i & "</b> "
  186.             Else
  187.                 strRet = strRet & "<a href=""" & strScript
  188.                 strRet = strRet & "page=" & i
  189.                 strRet = strRet & """>" & i & "</a>"
  190.                 If i <> intEnd Then strRet = strRet & " "
  191.             End If
  192.         Next
  193.     
  194.         If intPage <> intPageCount Then
  195.             strRet = strRet & " <a href=""" & strScript
  196.             strRet = strRet & "page=" & intPage + 1
  197.             strRet = strRet & """>Next&gt;&gt;</a> "
  198.         End If
  199.     End If
  200.     
  201.     Paging = strRet
  202. End Function
  203. %>
  204. <html>
  205. <head>
  206. <title>Surplus</title>
  207. <style>
  208. BODY
  209. {
  210.   FONT-WEIGHT: normal;
  211.   FONT-SIZE: 9pt;
  212.   COLOR: black;
  213.   FONT-FAMILY: Arial, Helvetica, sans-serif;
  214.   TEXT-DECORATION: none
  215. }
  216. TABLE
  217. {
  218.   FONT-WEIGHT: normal;
  219.   FONT-SIZE: 9pt;
  220.   COLOR: black;
  221.   FONT-FAMILY: Arial, Helvetica, sans-serif;
  222.   TEXT-DECORATION: none
  223. }
  224. A
  225. {
  226.   FONT-WEIGHT: normal;
  227.   FONT-SIZE: 9pt;
  228.   COLOR: blue;
  229.   FONT-FAMILY: Arial, Helvetica, sans-serif;
  230.   TEXT-DECORATION: underline
  231. }
  232. HR
  233. {
  234.   COLOR: #0072bc
  235. }
  236. </style>
  237. <script language="JavaScript" type="text/JavaScript">
  238. <!--
  239. function MM_jumpMenu(targ,selObj,restore){ //v3.0
  240.  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  241.  if (restore) selObj.selectedIndex=0;
  242. }
  243. //-->
  244. </script>
  245. </head>
  246. <body onload="javascript: document.frmSearch.category.select();">
  247. <table border="0" width="100%" cellpadding="2" cellspacing="2">
  248.  <tr>
  249.   <td align=center><h3>Surplus Search</h3></td>
  250.  </tr>
  251.  <tr>
  252.   <td><hr></td>
  253.  </tr>
  254.  <!--Search Form-->
  255.  <form name="frmSearch" method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
  256.   <input type="hidden" name="page" value="1">
  257.   <tr>
  258.    <td align=center> <table border="0" width="100%" cellpadding="2" cellspacing="2">
  259.      <tr>
  260.       <td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Search
  261.        by Category</font></td>
  262.      </tr>
  263.      <tr>
  264.       <td nowrap><b>Category</b></td>
  265.       <td width="100%"><input type="text" name="category" value="<%=Server.HTMLEncode(Request("Category"))%>" size="10">
  266.         </td>
  267.      </tr>
  268.      <tr>
  269.       <td height="27" nowrap><b>Subcategory</b></td>
  270.       <td width="100%"><input type="text" name="subcategory" size="20" value="<%=Server.HTMLEncode(Request("Subcategory"))%>">
  271.       </td>
  272.      </tr>
  273.      <tr>
  274.       <td height="19" colspan="2"><strong> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OR</strong></td>
  275.      </tr>
  276.      <tr>
  277.       <td height="19" colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Search
  278.        by Description</font></td>
  279.      </tr>
  280.      <tr>
  281.       <td nowrap><b>Description:</b></td>
  282.       <td><input type="text" name="description" size="20" value="<%=Server.HTMLEncode(Request("Description"))%>">
  283.        &nbsp;<font size="-2">(partial match)</font></td>
  284.      </tr>
  285.      <tr>
  286.       <td nowrap><b>Sort By:</b></td>
  287.       <td> <select name="sortby">
  288.         <option value="Category">Product category</option>
  289.         <option value="Subcategory"<%If Trim(LCase(Request("sortby"))) = "Subcategory" Then Response.Write " selected"%>>Product
  290.         subcategory</option>
  291.         <option value="Description"<%If Trim(LCase(Request("sortby"))) = "Description" Then Response.Write " selected"%>>Description</option>
  292.        </select>
  293.        &nbsp;
  294.        <select name="sortorder">
  295.         <option value="asc">Ascending</option>
  296.         <option value="desc"<%If Trim(LCase(Request("sortorder"))) = "desc" Then Response.Write " selected"%>>Descending</option>
  297.        </select> </td>
  298.      </tr>
  299.      <tr>
  300.       <td nowrap><b>Records Per Page:</b></td>
  301.       <td><input type="text" name="pagesize" size="10" value="<%=intPageSize%>"></td>
  302.      </tr>
  303.      <tr>
  304.       <td colspan="2"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  305.        <input type="submit" name="btnSubmit" value="Go!"> &nbsp; &nbsp;
  306.        <input type="button" name="btnRestart" value="Reset" onClick="javascript: window.location='<%=Request.ServerVariables("SCRIPT_NAME")%>'">
  307.        &nbsp; &nbsp; </td>
  308.      </tr>
  309.      <tr>
  310.       <td height="19" colspan="2">&nbsp;</td>
  311.      </tr>
  312.     </table></td>
  313.   </tr>
  314.  </form>
  315.  <tr>
  316.   <td><hr align="center"></td>
  317.  </tr>
  318.  <%If objRs.EOF Then%>
  319.  <!--No Records Found-->
  320.  <tr>
  321.   <td align="center"><b><font size="4">No products found!</font></b></td>
  322.  </tr>
  323.  <%Else%>
  324.  <!--Records Found-->
  325.  <tr>
  326.   <td> <table width="51%" border="0" align="center" cellpadding="3" cellspacing="3">
  327.     <tr>
  328.      <td colspan=4><b>Items Found: </b><%=objRs.RecordCount%></td>
  329.     </tr>
  330.     <tr>
  331.      <td align="center" colspan="4"><%=Paging(intPage, objRs.PageCount, objRs.RecordCount)%></td>
  332.     </tr>
  333.     <tr bgcolor="#efefef">
  334.      <td nowrap><b>Category</b></td>
  335.      <td nowrap><b>Subcategory</b></td>
  336.      <td nowrap width="100%"><b>Description</b></td>
  337.      </tr>
  338.     <%
  339.                 If objRs.PageCount < intPage Then intPage = objRs.PageCount
  340.                 objRs.AbsolutePage = intPage
  341.                 
  342.                 Dim strRowColor
  343.                 strRowColor = "#ffffff"
  344.                 
  345.                 Do While Not objRs.EOF And intRecord <= intPageSize
  346.                     %>
  347.     <tr bgcolor="<%=strRowColor%>">
  348.      <td nowrap><%=objRs("Category").Value%></td>
  349.      <td nowrap><%=objRs("Subcategory").Value%></td>
  350.      <td><%=objRs("Description").Value%></td>
  351.     </tr>
  352.     <%
  353.                     If strRowColor = "#ffffff" Then strRowColor = "#CCCCCC" Else strRowColor = "#ffffff"
  354.                     intRecord = intRecord + 1
  355.                     objRs.MoveNext
  356.                 Loop
  357.                 %>
  358.     <tr>
  359.      <td colspan="4"><hr></td>
  360.     </tr>
  361.     <tr>
  362.      <td align="center" colspan="4"><%=Paging(intPage, objRs.PageCount, objRs.RecordCount)%></td>
  363.     </tr>
  364.    </table></td>
  365.  </tr>
  366.  <tr>
  367.   <td><hr></td>
  368.  </tr><br>
  369.  <tr><td></td></tr>
  370.  <%End If%>
  371. </table>
  372. </body>
  373. </html>
  374. <%
  375. 'Object cleanup
  376. If IsObject(objRs) Then
  377.     If Not objRs Is Nothing Then
  378.         If objRs.State = adStateOpen Then objRs.Close
  379.         Set objRs = Nothing
  380.     End If
  381. End If
  382. If IsObject(objCn) Then
  383.     If Not objCn Is Nothing Then
  384.         If objCn.State = adStateOpen Then objCn.Close
  385.         Set objCn = Nothing
  386.     End If
  387. End If
  388. %>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Perhaps I'm overlooking something, but I think your problem is making the connection to the database. Check out this tutorial on making the connection and see if one of those methods will work for you:

http://www.tnsites.com/support/s_databaseconn.asp
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

This is an example of what your using and not the EXACT code right ?

Quote:
Server.MapPath("Database File Path Goes Here")
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Try turning off "Friendly HTTP Error Messages" in IE and see if it will tell you what line the error is on... (Tools > Internet Options > Advanced. Under Browsing, uncheck the box next to "Show friendly HTTP error messages")

.c
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Also, if you have control over your own IIS server, you should have access to Microsoft's Development Environment, normally located here:

"C:\Program Files\Microsoft Visual Studio\Common\IDE\IDE98\MSE.EXE"

In the options, you can turn on the "just-in-time" debugger. A very handy tool for asp scripts written in VB.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 70 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.