Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP 3.0 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 May 4th, 2004, 10:22 PM
Registered User
 
Join Date: Jan 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 15 (Bid.asp)

Hello, I am muddling my way through this chapter and have encountered a few problems but solved them through thorough detective work. Usually it is a punctuation or missing quote. This time I seem to have hit a wall.

This is the error I am getting now in my debugging process. I found some others and corrected them, but this one is stumping me:

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression 'ItemID ='.
/aspfiles/bid.asp, line 18

I am even getting this error with the book code. I checked my Access file and nothing seems to be amiss. All headers are written correctly (i.e. "ItemID" not "Item ID")

Here is the code with the offending line. The error seems to be pointing to the 'strSQL = "SELECT * FROM Item...." line.
<%
    dim rsItem, strItemName, strDescription
    Set rsItem = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM Item WHERE ItemID =" & Request("Item")
    rsItem.Open strSQL, objConn
    strItemName = rsItem("ItemName")
    strDescription = rsItem("Description")
    rsItem.Close
    set rsItem = Nothing

    dim rsBids
    set rsBids = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM Bid WHERE ItemID =" & Request("Item") &_
        " ORDER BY TimeStamp DESC;"
    rsBids.Open strSQL, objConn
%>
<center><h1> Wrox Classifieds<br>Bidding for <%= strItemName %><h1><center>

Any Suggestions? BTW, I am assuming I will get a similar error when the next strSQL line is executed ("SELECT * FROM Bid...")

Thanks in advance for your help.


Thanks,
JB977
 
Old May 5th, 2004, 02:43 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

It looks like Request("Item") does not have a value. Should it get that from a previous page? Look at the SQL statement to know for sure. To do that, make the following changes to your code, and post the output from the Write statement to this forum:
Code:
Set rsItem = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Item WHERE ItemID =" & Request("Item")
Response.Write("SQL is " & strSQL)
Response.End
rsItem.Open strSQL, objConn
This should result in the SQL statement being written to the browser, so you can see if it is a valid SQL statement.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 5th, 2004, 08:32 PM
Registered User
 
Join Date: Jan 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Imar
 Hi there,

It looks like Request("Item") does not have a value. Should it get that from a previous page? Look at the SQL statement to know for sure. To do that, make the following changes to your code, and post the output from the Write statement to this forum:
Code:
Set rsItem = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Item WHERE ItemID =" & Request("Item")
Response.Write("SQL is " & strSQL)
Response.End
rsItem.Open strSQL, objConn
This should result in the SQL statement being written to the browser, so you can see if it is a valid SQL statement.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Thanks for the tip. I will try that and let you know what the results were. BTW the Request("Item") seems to point to the Access table "Item" correct? if so it is named properly since I checked w/ the other pages like browselistings.asp and it calls up the info from the table.

Stay tuned for the results.

Thanks,
JB977
 
Old May 5th, 2004, 09:01 PM
Registered User
 
Join Date: Jan 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hmmm,

Got it. I think I was supposed to go from the browse listings page and click on a item---as per the books instructions. oops. Thanks for your help anyways. Gotta read things a little closer I guess. (embarrassed)

I am almost done with the chapter so I should be ok from here on. Once I start applying what I learned, I might be back.



Thanks,
JB977
 
Old May 6th, 2004, 02:12 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Request("Item") does not point to something in the database, but to a variable retrieved from a page submitted to the page you're using it on.
When you have a page with a <form> tag that has a method set to GET or POST the page will submit to another page (or itself). You can then use Request(NameOfFormElement) to retrieve the value of the form element.

It's also possible to pass values through the querystring directly, e.g. <a href="MyPage.asp?ITEM=4">Click</a>
This will sent the QueryString variable to the MyPage.asp page where you can retrieve it with Request("ITEM").

It's usually a good idea to check for the presence of Request("Item") and other variables, before you execute your query, to prevent errors like this, e.g.:
Code:
If Len(Request("Item")) = 0 Then
  Response.Write("Sorry, you cannot access this page directly")
Else
  ' Request("Item") looks good, so continue
End If
HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: No Hope by Motorpsycho (Track 4 from the album: Wrenched) What's This?
 
Old May 28th, 2004, 01:49 AM
Registered User
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi this is babar
i have problem that
i want to email vai ASP and the code use like
Dim myMail
Set myMail = CreateObject("CDONTS.NewMail")

myMail.From="[email protected]"
myMail.To="[email protected]"
myMail.Subject="Request for Info"
myMail.BodyFormat=0
myMail.MailFormat=0
myMail.Body=FormBody 'input data consolidated to FormBody
myMail.Send
set mymail=nothing

plz tell me is it true or not
or how it can work

 
Old May 28th, 2004, 02:07 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Is this related to the original post you replied to? If not, you may be better off starting a new topic.

What do you want us to tell "that is true"? Are you having problems with your code?

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 15 - item.asp Joe Kerr BOOK: Beginning ASP 3.0 1 February 7th, 2006 06:42 PM
Beginning asp 3.0: Chapter 15 karoshi BOOK: Beginning ASP 3.0 1 March 10th, 2005 05:58 PM
Syntax error for chapter 15 AddUser.asp gymmic Classic ASP Databases 7 April 20th, 2004 02:00 AM
Chapter 15, page 648-649 (Beginning ASP 3.0) JB977 Wrox Book Feedback 0 February 16th, 2004 05:27 PM
Problem with Chapter 15 - BrowseListings.asp Giuliano BOOK: Beginning ASP 3.0 1 August 7th, 2003 01:36 PM





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