Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 14th, 2004, 12:13 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default error while trying to display db info

I have these 2 pages (search/display), search sends over the ID of the item which was selected, allowing me to display the selected items. I'm getting this error now, even if I hard code the data "select * from Recipe where ID = '1'", it still gives me to same error message... Any ideas as to what I'm doing wrong???

Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
/cookbook/display.asp, line 16


line 16 -> Set rs = db.Execute ("SELECT * FROM Recipe WHERE ID = '"&recipe_ID&"'")

<body>
<%
 recipe_ID = Request.Form("recipe_name")
 if (IsEmpty(recipe_ID)) = TRUE then
  response.Write("")
 else
  Set db = Server.CreateObject("ADODB.Connection")
  db.Open = "Cookbook"

  Set rs = db.Execute ("SELECT * FROM Recipe WHERE ID = '"&recipe_ID&"'")
   meal = rs("R_name")
   category = rs("R_category")
   instructions = rs("R_instructions")
   ingredients = rs("R_ingredients")
   picture = rs("R_picture")
 end if
%>
<h1><%=meal%></h1>

<table width=100%>
 <tr><td><b>Ingredients</b><br>
 [list]
  <%
   dim arringredients
   arringredients = Split(ingredients, ",")
   for i=0 to UBound(arringredients)
    Response.Write "<li>"&arringredients(i)&"</li>"
   next
  %>
 </ul></td>
 <td>
  <img src="<%=picture%>" alt="<%=meal%>" border="0" width="200" height="200">
 </td>
 </tr>
</table>

<b>Instructions</b><br>
<%
 Dim arrinstruct
 arrinstruct = Split (instructions,":")
 for j=0 to UBound(arrinstruct)
  k = j+1
  Response.Write("<b>Step "&k&" </b>"&arrinstruct(j)&"<br>")
 next
%>



 
Old March 14th, 2004, 06:59 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

If the ID in the table Recipe is a Number, you shouldn't enclose it's value in quotes:

Set rs = db.Execute ("SELECT * FROM Recipe WHERE ID = " & recipe_ID)

You should use quotes only for data types like text and dates.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Display img from db: error on Windows Server author05 Classic ASP Databases 0 February 21st, 2008 09:45 AM
ServerFileReportService Db Info at Runtime jason_l_riley BOOK: Professional Crystal Reports for VS.NET 0 January 15th, 2006 09:29 PM
display an image (more info) gorney .NET Web Services 0 December 29th, 2003 02:32 PM
How Can I Add Info From a Txt File Into a DB? Lucy Classic ASP Professional 3 October 21st, 2003 11:00 AM
info from pg won't post to db scottiegirl PHP Databases 3 September 26th, 2003 12:48 PM





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