Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 SQL statement help
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

es4725
Junior Member

205 Posts

Posted - 15 March 2002 :  12:23:14  Show Profile
My SQL statement currently looks like this:

SELECT * FROM course WHERE Level <=9

I need to select a few columns (CourseID, CourseTitle, CourseSubTitle, Level, Credit, Coreq, and Prereq) and I need another option in the WHERE statement. I need it to be where Level <=9 (as it is) and also where Department = a string that will be varied dependant on a users click - say strDep for example. I don't remember right off the top of my head how it needs to be formatted, any help would be appreciated. Thanks

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 15 March 2002 :  12:29:27  Show Profile  Send ruirib a Yahoo! Message
quote:

My SQL statement currently looks like this:

SELECT * FROM course WHERE Level <=9

I need to select a few columns (CourseID, CourseTitle, CourseSubTitle, Level, Credit, Coreq, and Prereq) and I need another option in the WHERE statement. I need it to be where Level <=9 (as it is) and also where Department = a string that will be varied dependant on a users click - say strDep for example. I don't remember right off the top of my head how it needs to be formatted, any help would be appreciated. Thanks



Probably something like this:


strSql = "SELECT CourseID, CourseTitle, CourseSubTitle, Level, Credit, Coreq, Prereq FROM course WHERE (Level<=9) AND (Department=" & strDep & ");"



-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 16 March 2002 :  01:58:12  Show Profile
Thanks Rui - I'll give that a go and let you know.

Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 19 March 2002 :  12:00:19  Show Profile
I get this error:

The LEVEL clause includes a reserved word or argument that is misspelled or missing, or the punctuation is incorrect.

is LEVEL a reserved Word?

Go to Top of Page

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 19 March 2002 :  12:09:04  Show Profile  Visit Kat's Homepage
Yep sure is. You'll need to change it.

see here: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q109312

KatsKorner

For Installation help: http://www.aslickpage.com/snitz_help.html
For Snitz Mods: http://ls3k.com/snitz/

Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 19 March 2002 :  12:18:31  Show Profile
that's odd - it hasn't given me any problems until now... alright - guess I'll have to change it though...

Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 19 March 2002 :  13:27:51  Show Profile  Send ruirib a Yahoo! Message
If you want you can just use SELECT * FROM ..., instead of specifying all the fields you want.
It will be a bit less efficient but won't force you to rename the field...

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 19 March 2002 :  21:02:16  Show Profile
I may do that for now... Thanks Rui... temporarily saved me some work...

Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 19 March 2002 :  21:24:01  Show Profile  Send ruirib a Yahoo! Message
You are welcome .

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 20 March 2002 :  07:11:24  Show Profile
Now I'm getting another error Something along the lines of "No value given for required parameter" or something like that. I think the server just went down right after I hit refresh - so I can't really say for sure... when I find out I'll post here...Error is down below

This is what it looks like now by the way:

strSQLCourseFreshman = "SELECT * FROM course WHERE (Level<=9) AND (Department=" & strDep & ");"


*edit*
Server's back up. Here's the error message:

No value given for one or more required parameters

*/edit*


Edited by - es4725 on 20 March 2002 07:14:23
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 20 March 2002 :  07:33:00  Show Profile  Send ruirib a Yahoo! Message
Please post the value of the strSQLCourseFreshman variable.
Just Response.Write its value so that we know the SQL string that is being sent to the database.

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs



Edited by - ruirib on 20 March 2002 07:36:39
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 20 March 2002 :  08:13:45  Show Profile  Visit Gremlin's Homepage
Its still the same problem as above I suspect, you still have level in the query and it might be trying to parse that as something else,

try


strSQLCourseFreshman = "SELECT * FROM course WHERE ([Level]<=9) AND (Department=" & strDep & ");"


www.daoc-halo.com
Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 20 March 2002 :  08:15:28  Show Profile
Here it is:

SELECT * FROM course WHERE (Level<=9) AND (Department=Math);


Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 20 March 2002 :  08:19:31  Show Profile
quote:


strSQLCourseFreshman = "SELECT * FROM course WHERE ([Level]<=9) AND (Department=" & strDep & ");"



No go either... I don't think it's a problem with Level. If I delete "AND (Department=" & strDep & ");", then the sql call functions, not with the desired results obviously, but it does call * FROM course WHERE (Level<=9) without a problem.

*edit*
I'll be back on in about 3 1/2 hours at school, gotta get there now though.
*/edit*


Edited by - es4725 on 20 March 2002 08:21:34
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 20 March 2002 :  08:23:21  Show Profile  Send ruirib a Yahoo! Message
To Gremlin: I don't think it is due to Level in the WHERE. I tried using it in a DB of my own and I only got problems when using Level in the SELECT part.

I suppose Math is a string, right?

Change your code to this:

strSQLCourseFreshman = "SELECT * FROM course WHERE (Level<=9) AND (Department=""" & strDep & """);"




-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 20 March 2002 :  08:31:05  Show Profile  Visit Gremlin's Homepage
I haven't used access alot so I'm not 100% up with the correct syntax, quotes around 'math' maybe required ?

EDIT: Doh beaten to it

www.daoc-halo.com

Edited by - Gremlin on 20 March 2002 08:31:37
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.23 seconds. Powered By: Snitz Forums 2000 Version 3.4.07