p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Databases (http://p2p.wrox.com/forumdisplay.php?f=62)
-   -   Inconsistent error when retrieving data from a db (http://p2p.wrox.com/showthread.php?t=10489)

darkhalf March 13th, 2004 08:15 PM

Inconsistent error when retrieving data from a db
 
I sometimes get this error, but after a few tries it works, I don't understand what I'm doing wrong.

Error Type:
Provider (0x80004005)
Unspecified error
/cookbook/search.asp, line 109

here is the code...

<script language="JavaScript">
function SetInfo_href(url)
{
href = new Array ('A-F','G-L','M-R','S-Z','all');
s = document.Search;
s.search_field.value = "alpha="+href[url];
s.submit();
}
function SetInfo()
{
s = document.Search;
meal = s.meal.value;
category = s.category.options[s.category.selectedIndex].value;
ingredients = s.ingredients.value;

if (meal != "")
{
s.search_field.value = "meal="+meal;
s.submit();
}
else if (category != "")
{
s.search_field.value = "category="+category;
s.submit();
}
else if (ingredients != "")
{
s.search_field.value = "ingredients="+ingredients;
s.submit();
}
}
function submit_recipe(ID)
{
document.SS.recipe_name.value = ID;
document.SS.submit();
// document.write (ID)
}
</script>
</head>
<body>
<form name="Search" method="post" action="search.asp">
<table>
<tr>
<td>Name of meal:</td>
<td><input type="text" name="meal" size="14"></td>
</tr>
<tr>
<td>Category:</td>
<td><select name="category">
<option value=""></option>
<option value="Appitizer">Appitizer</option>
<option value="Bread">Bread</option>
<option value="Breakfast">Breakfast</option>
<option value="Desert">Desert</option>
<option value="MainCourse">Main Course</option>
<option value="Soups">Soups</option>
<option value="Other">Other</option>
</select></td>
</tr>
<tr>
<td>Ingredients:</td>
<td><input type="text" name="ingredients" size="14"></td>
</tr>
<tr>
<td colspan="2" align="center">
<a href="java_script_:SetInfo_href(0)">A-F</a> |
<a href="java_script_:SetInfo_href(1)">G-L</a> |
<a href="java_script_:SetInfo_href(2)">M-R</a> |
<a href="java_script_:SetInfo_href(3)">S-Z</a>
</td>
</tr>
<tr>
<td colspan="2" align="center"><a href="java_script_:SetInfo_href(4)">All</a></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" value="Submit" onClick="SetInfo()"></td>
<td colspan="2" align="center"><input type="hidden" value="" name="search_field"></td>
</tr>
</table>
</form>
<%
search_string = Request.Form("search_field")
if IsEmpty(search_string) = TRUE then
Response.Write("")
else
arrsearch = Split(search_string,"=")
Select Case arrsearch(0)
Case "meal"
query = "SELECT * FROM Recipe WHERE R_name='"&arrsearch(1)&"'"
Case "category"
query = "SELECT * FROM Recipe WHERE R_category='"&arrsearch(1)&"'"
Case "ingredients"
query = "SELECT * FROM Recipe WHERE R_ingredients LIKE '%"&arrsearch(1)&"%'"
end Select
Set db = Server.CreateObject("ADODB.Connection")
db.open "Cookbook"

Set rs = db.Execute (query)

if rs.EOF and rs.BOF then
Response.Write("There are no recipes that match that criteria")
else
rs.movefirst
while not rs.EOF
Response.Write ("<a href=java_script_:submit_recipe("&rs("ID")&")>"&rs ("R_name")&"</a>")
rs.MoveNext
wend
end if

end if
%>
<form name="SS" method="post" action="display.asp">
<input type="hidden" name="recipe_name" value="">
</form>



darkhalf March 13th, 2004 08:57 PM

Also, as a side not, the line that it fails on is:
db.open "Cookbook"


darkhalf March 14th, 2004 12:38 PM

Thank you very much, I didn't know that numbers were not supposed to be encapsulated in '




All times are GMT -4. The time now is 04:36 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.