|
-
Jun 27th, 2001, 09:56 PM
#1
Thread Starter
Hyperactive Member
quote error in query
Hello kids! Its time to play WHATS WRONG WITH THIS CODE!!!!
Lets meet contestant number one. This sloppy programmer wants to have some values he gets from a form to be queried against his Access database. When inserting the variable values into his query using some sloppy code like
strQuery = strQuery & "SELECT * HAVING price BETWEEN '" & fromPrice & "' AND '" & toPrice & "'"
...
He gets errors!!!!
For 500 points, can somebody tell me WHATS WRONG WITH THIS CODE!?!?!
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
-
Jun 28th, 2001, 03:00 AM
#2
wow 500 points 
Code:
strQuery = strQuery & "SELECT * HAVING price BETWEEN '" & _
"fromPrice & "' AND '" & toPrice & "'"
You haven't got a from clause in there !
In a Select statement, you need to specify which table you need to get this from :
Code:
strQuery = strQuery & "SELECT * FROM Table1 HAVING price BETWEEN '" & _
fromPrice & "' AND '" & toPrice & "'"
Also, you might want to check in debug mode the values of fromPrice & toPrice to make sure they're entered right - maybe using cint(toPrice) to convert this to a number before passing it in ?
Last edited by alex_read; Jun 28th, 2001 at 03:34 AM.
-
Jun 28th, 2001, 03:11 AM
#3
Thread Starter
Hyperactive Member
oooooh sorry but that is not the correct answer!
The sloppy programmer does have a from clause in the next lines of code.
We here at WHATS WRONG WITH THIS CODE think it has something to do with the quotes.
If you get it right this time, you might move up to the next round.
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
-
Jun 28th, 2001, 03:32 AM
#4
-
Jun 28th, 2001, 03:36 AM
#5
Thread Starter
Hyperactive Member
You've been a great contestant!
Tell him what he won, Bob
Until next time
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|