Print Page | Close Window

no records found from SQL DB=problems

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=9871
Printed Date: 28 March 2026 at 11:59pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: no records found from SQL DB=problems
Posted By: neosarcastic
Subject: no records found from SQL DB=problems
Date Posted: 16 February 2004 at 3:08pm

Here's a new one i am having trouble with...

I am using Dreamweaver with ASP connected to SQL 2000.
I have constructed a search and results page...which works great, except that when i miss-spell a search parameter, it shows an error 500 on every pc on the network.  There is a dreamweaver tutorial that has shown me how to display empty records on the results page should there be no match to my query.  This is fine except users don't get as far as the results page.  if they have miss-spelled criteria or they have searched for a record that does not exist I would like them to see "sorry no records found" like I said Dreamweaver shows us how to do this but the tutorial assumes that we see the results page. After submitting it just goes to a 500 - internal server error.

Is this something i can solve with code on the search/results page or is this an SQL thing?  (I don't believe it is an SQL thing as the current intranet connected to the database does not have these issues)

any ideas would be great.

 

Thanks




Replies:
Posted By: Semikolon
Date Posted: 16 February 2004 at 3:13pm
  1. Drop the dreamweaver code and write all yourself
  2. turn off friendly http error messages in IE
  3. post the error here


Posted By: neosarcastic
Date Posted: 16 February 2004 at 3:19pm
great, if I were an ASP writer but I am not, never claimed to be, and never want to be.  That is why I have DW.  "Show friendly HTTP error messages" is turned off, still does the same thing.  If there is a snippet of code somewhere that I can insert/learn than great.


Posted By: Semikolon
Date Posted: 16 February 2004 at 3:24pm

generated code is really hard to edit, so it might not be easy to help you with this..

can you paste the error message you get? including the line and some of the lines before the error line



Posted By: neosarcastic
Date Posted: 17 February 2004 at 7:58am

Thanks for offering your help,
The error page shows code, i know there is a response.write trick but i cannot figure that out.  So this is the actual code that shows in the browser when i search for criteria that is not matching in the DB.

<%@ language="VBScript" %>
<%
  Option Explicit

  Const lngMaxFormBytes = 200

  Dim objASPError, blnErrorWritten, strServername, strServerIP, strRemoteIP
  Dim strMethod, lngPos, datNow, strQueryString, strURL

  If Response.Buffer Then
    Response.Clear
    Response.Status = "500 Internal Server Error"
    Response.ContentType = "text/html"
    Response.Expires = 0
  End If

  Set objASPError = Server.GetLastError
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<html  dir=ltr>

<head>
<style>
a:link			{font:8 pt/11pt verdana; color:FF0000}
a:visited		{font:8pt/11pt verdana; color:#4e4e4e}
</style>

<META NAME="ROBOTS" CONTENT="NOINDEX">

<title>The page cannot be displayed</title>

<META HTTP-EQUIV="Content-Type" Content="text-html; charset=Windows-1252">
</head>

<script> 
function Homepage(){
<!--
// in real bits, urls get returned to our script like this:
// res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm 

	//For testing use DocURL =  "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/ba r.htm"
	DocURL=document.URL;
	
	//this  is where the http or https will be, as found by searching for :// but skipping the res://
	protocolIndex=DocURL.indexOf("://",4);
	
	//this finds the ending slash for the domain server 
	serverIndex=DocURL.indexOf("/",protocolIndex + 3);

	//for the href, we need a valid URL to the domain. We search for the # symbol to find the begining 
	//of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.
	//urlresult=DocURL.substring(protocolIndex - 4,serverIndex);
	BeginURL=DocURL.indexOf("#",1) +  1;
	urlresult=DocURL.substring(BeginURL,serverIndex);
		
 	//for display, we need to skip after http://, and go to the next slash
	displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);
	InsertElementAnchor(urlresult, displayresult);
}

function HtmlEncode(text)
{
    return text.replace(/&/g, '&amp').replace(/'/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}

function TagAttrib(name, value)
{
    return ' '+name+'="'+HtmlEncode(value)+'"';
}

function PrintTag(tagName, needCloseTag, attrib, inner){
    document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) );
    if (needCloseTag) document.write( '</' + tagName +'>' );
}

function URI(href)
{
    IEVer = window.navigator.appVersion;
    IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 );

    return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ?
        encodeURI(href) :
        escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');
}

function InsertElementAnchor(href, text)
{
    PrintTag('A', true, TagAttrib('HREF', URI(href)), text);
}

//-->
</script>

<body bgcolor="FFFFFF">

<table width="410" cellpadding="3" cellspacing="5">

  <tr>    
    <td align="left" valign="middle" width="360">
	<h1 style="COLOR:000000; FONT: 13pt/15pt verdana"><!--Problem-->The page cannot be displayed</h1>
    </td>
  </tr>
  
  <tr>
    <td width="400" colspan="2">
	<font style="COLOR:000000; FONT: 8pt/11pt verdana">There is a problem with the page you are trying to reach and it cannot be displayed.</font></td>
  </tr>
  
  <tr>
    <td width="400" colspan="2">
	<font style="COLOR:000000; FONT: 8pt/11pt verdana">

	<hr color="#C0C0C0" noshade>
	
    <p>Please try the following:</p>

	<ul>
      <li id="instructionsText1">Click the 
      <a href="javascript:location.reload()">
      Refresh</a> button, or try again later.<br>
      </li>
	  
      <li>Open the 
	  
	  <script>
	  <!--
	  if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2")))
	  {
	  	 Homepage();
	  }
	  //-->
	  </script>

	  home page, and then look for links to the information you want. </li>
    </ul>
	
    <h2 style="font:8pt/11pt verdana; color:000000">HTTP 500.100 - Internal Server
    Error - ASP error<br>
    Internet Information Services</h2>

	<hr color="#C0C0C0" noshade>
	
	<p>Technical Information (for support personnel)</p>

<ul>
<li>Error Type:<br>
<%
  Dim bakCodepage
  on error resume next
	  bakCodepage = Session.Codepage
	  Session.Codepage = 1252
  on error goto 0
  Response.Write Server.HTMLEncode(objASPError.Category)
  If objASPError.ASPCode > "" Then Response.Write Server.HTMLEncode(", " & objASPError.ASPCode)
  Response.Write Server.HTMLEncode(" (0x" & Hex(objASPError.Number) & ")" ) & "<br>"

  If objASPError.ASPDescription > "" Then 
		Response.Write Server.HTMLEncode(objASPError.ASPDescription) & "<br>"

  elseIf (objASPError.Description > "") Then 
		 Response.Write Server.HTMLEncode(objASPError.Description) & "<br>" 
  end if



  blnErrorWritten = False

  ' Only show the Source if it is available and the request is from the same machine as IIS
  If objASPError.Source > "" Then
    strServername = LCase(Request.ServerVariables("SERVER_NAME"))
    strServerIP = Request.ServerVariables("LOCAL_ADDR")
    strRemoteIP =  Request.ServerVariables("REMOTE_ADDR")
    If (strServername = "localhost" Or strServerIP = strRemoteIP) And objASPError.File <> "?" Then
      Response.Write Server.HTMLEncode(objASPError.File)
      If objASPError.Line > 0 Then Response.Write ", line " & objASPError.Line
      If objASPError.Column > 0 Then Response.Write ", column " & objASPError.Column
      Response.Write "<br>"
      Response.Write "<font style=""COLOR:000000; FONT: 8pt/11pt courier new""><b>"
      Response.Write Server.HTMLEncode(objASPError.Source) & "<br>"
      If objASPError.Column > 0 Then Response.Write String((objASPError.Column - 1), "-") & "^<br>"
      Response.Write "</b></font>"
      blnErrorWritten = True
    End If
  End If

  If Not blnErrorWritten And objASPError.File <> "?" Then
    Response.Write "<b>" & Server.HTMLEncode(  objASPError.File)
    If objASPError.Line > 0 Then Response.Write Server.HTMLEncode(", line " & objASPError.Line)
    If objASPError.Column > 0 Then Response.Write ", column " & objASPError.Column
    Response.Write "</b><br>"
  End If
%>
</li>
<p>
<li>Browser Type:<br>
<%=  Server.HTMLEncode(Request.ServerVariables("HTTP_USER_AGENT") )  %>
</li>
<p>
<li>Page:<br>
&l t;%
  strMethod = Request.ServerVariables("REQUEST_METHOD")

  Response.Write strMethod & " "

  If strMethod = "POST" Then
    Response.Write Request.TotalBytes & " bytes to "
  End If

  Response.Write Request.ServerVariables("SCRIPT_NAME")

  lngPos = InStr(Request.QueryString, "|")

  If lngPos > 1 Then
    Response.Write "?" & Server.HTMLEncode(Left(Request.QueryString, (lngPos - 1)))
  End If

  Response.Write "</li>"

  If strMethod = "POST" Then
    Response.Write "<p><li>POST Data:<br>"
    If Request.TotalBytes > lngMaxFormBytes Then
       Response.Write Server.HTMLEncode(Left(Request.Form, lngMaxFormBytes)) & " . . ."
    Else
      Response.Write Server.HTMLEncode(Request.Form)
    End If
    

         


Posted By: Mart
Date Posted: 17 February 2004 at 9:30am

Is that directly from your browser? There shouldnt be any ASP inside it... Are you sure you didnt paste the 500 error pages source code?



Posted By: neosarcastic
Date Posted: 17 February 2004 at 10:04am

That is what shows in my browser... i know it is weird.  Using IIS 5.0(which is successfully serving a current/old ASP intranet with no problems.)  This is all DW's doing I think, and I am disgusted with it's performance.  However I still have to solve this.  The error is an ASP 500 error, usually isn't this a permission error?

Thanks



Posted By: Semikolon
Date Posted: 17 February 2004 at 12:07pm
isnt this the 500 error page source code?


Posted By: neosarcastic
Date Posted: 17 February 2004 at 12:51pm

Yes it is the source code for the error page, this is exactly what the broswer shows me, it is not formatted by html or anything..?  this is strange but I have found a way to customize the IIS 500 error pages.  so this is what i was able to pull:

ASP 500 Error
An error occurred processing the page you requested.
Please see the details below for more information.

COM Error Number -2146825267 (0x800A0BCD)
File Name /pftintranet/vendorresults.asp
Line Number 286
Brief Description Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. 
BUT:
Line 286, is:
<td width="182"> <span class="style12"> <%=(Recordset1.Fields.Item("VendorName").Value)%> </span> </td>

 



Posted By: Semikolon
Date Posted: 17 February 2004 at 12:57pm

change line 286 to

If Not Recordset1.EOF Then Response.Write(Recordset1.Fields.Item("VendorName").Value)



Posted By: Mart
Date Posted: 17 February 2004 at 2:17pm
You sure that your server has ASP installed? The source code sholdn't get to the browser


Posted By: Semikolon
Date Posted: 17 February 2004 at 2:28pm

i think theres a problem with the server yeah..

you are running IIS right?

im not sure if ASP is installed by default, so you might check if it is



Posted By: Mart
Date Posted: 17 February 2004 at 2:31pm
ASP is installed by default...


Posted By: neosarcastic
Date Posted: 17 February 2004 at 2:37pm

Thank you semikolon, I appreciate all your help, this I beleive will work as I have come across that piece of code earlier on a site and it was to be a suggestion in my next post. 

 

I know that ASP is installed on this server as it has been serving our current Intranet that is ASP for some time now.  I am building it's replacment. 

In case this line does not work I think I am content with customizing the error page to say: "Sorry, no results found"

Once again thank-you and i will post the result of that line.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net