ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 18th, 2002, 10:58 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 16
Send a message via MSN to aspnewbie
Syntax Error in Group By/Having/Order By Statement

I'm having this very stupid problem with my sql statement for an asp page I'm writing. I keep getting a syntax error and it's making me mental . The answer is probably so basic, but I can't seem to figure it out.

Here's the part of the code where there's a problem

Code:

strSQL = strSQL & "HAVING Items.ItemID=" & ID
strSQL = strSQL & "ORDER BY Bids.BidAmount DESC "


What's the proper syntax around the ID? The ID is a variable.

Thanks all.

Reply With Quote
  #2  
Old September 19th, 2002, 10:01 AM
markerdave markerdave is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Illinois, USA
Posts: 71 markerdave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
aspnewbie,

Hi! Is you ID variable a number or something else?
If it is not a number, it needs to be put inside of single quotations like:

"HAVING Items.ItemID='" & ID & "'"
__________________
Oh I wish, I wish I hadn't killed that fish...

Reply With Quote
  #3  
Old September 19th, 2002, 01:24 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 16
Send a message via MSN to aspnewbie
it is a number.

I figured it out though! I was just missing a stupid space between the quote and the order by statement. Then it worked fine.

How picky!

Thanks anyway.

Reply With Quote
  #4  
Old September 19th, 2002, 01:50 PM
markerdave markerdave is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Illinois, USA
Posts: 71 markerdave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
I cannot believe I wrote "Is you variable." I feel stupid.

That would be a tough one to spot, but I guess without that space it would be one word instead of two.

Reply With Quote
  #5  
Old September 19th, 2002, 03:48 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 16
Send a message via MSN to aspnewbie
David,

Any thoughts on this one:

I'm trying to set up a SQL statement so that all the bidders except for the currentbidder receive an email saying that the currentbidder has made a bid.

Here's the problem code:

Code:
strOtherBidders = strOtherBidders & "HAVING ItemID=" & iItemID 
strOtherBidders = strOtherBidders & " and BidderEmail <> " & rsData("BidderEmail") 


Error - Syntax error (missing operator) in query expression. I think it's the "not the email address" that is causing the problem. Should that be written differently?

BidderEmail is an email address (surprise).

(I know, I know I should be using an id, but I had to simplify my database. Bad, bad)

Thanks a lot.

Reply With Quote
  #6  
Old September 19th, 2002, 04:53 PM
markerdave markerdave is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Illinois, USA
Posts: 71 markerdave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Everything looks syntactically correct except that the email does need to be in single quotes since it is not a number. If that is not it then can you list some more of the SQL query?

Reply With Quote
  #7  
Old September 19th, 2002, 06:43 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 16
Send a message via MSN to aspnewbie
Solved this one!

Defined rsData("BidderEmail") as CurrentBidderEmail, then enclosed it in single quotes (as you suggested), then changed the order of the statements so that the itemID was the last statement and now it seems to work fine. Yeah!

Going from memory, it ended up looking like this

Code:
"HAVING BidderEmail <>" & 'CurrentBidderEmail' 
" and ItemID=" & iItemID 


Thanks again.

Onto the next SQL challenge/frustration ...

Reply With Quote
  #8  
Old September 19th, 2002, 10:33 PM
markerdave markerdave is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Illinois, USA
Posts: 71 markerdave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Question

I am not sure why the change worked to tell you the truth. I was thinking more along the lines of this


Code:
"HAVING BidderEmail <>'" & CurrentBidderEmail & "'" 


Any SQL query where you search for a string like that has to have the string in single quotes which without the ASP part would be something like

WHERE Name='David'

Just in case you want to know.

Reply With Quote
  #9  
Old September 23rd, 2002, 03:01 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 16
Send a message via MSN to aspnewbie
David,

Just checked my code again and I actually wrote it as you had suggested afterall (my faulty memory!).

It's frustrating though because sometimes it sends it to the currentbidder instead of sending it to everyone else! Would you mind having a look at the code. Can I email it to you?

Reply With Quote
  #10  
Old September 23rd, 2002, 04:26 PM
markerdave markerdave is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Illinois, USA
Posts: 71 markerdave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Yeah, go ahead and email it to me. I'll take a look at it and give you any help I can.

Reply With Quote
  #11  
Old September 26th, 2002, 09:43 AM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 16
Send a message via MSN to aspnewbie
David,

I need your email address (can you add it to your profile or email me?)

Thanks so much for agreeing to do this!

Reply With Quote
  #12  
Old September 26th, 2002, 10:09 AM
markerdave markerdave is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Illinois, USA
Posts: 71 markerdave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Sorry about that. I didn't realize that I had that feature turned off. It is on now so you should be able to email me.

Reply With Quote
  #13  
Old September 26th, 2002, 01:37 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 16
Send a message via MSN to aspnewbie
Here's the file. Being relatively new to ASP, I write really klunky code, so feel free to make suggestions on how I can improve it.
Attached Files
File Type: txt addbid.txt (2.7 KB, 799 views)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Syntax Error in Group By/Having/Order By Statement


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap