Sign in to follow this  
chbrules

[ASP] Query problems

Recommended Posts

I'm trying to run this query to my database, but the ORDER BY never seems to work, it's not arranging the record set the way I want (desc/asc). Can anyone tell me why? I've checked the values of order_by and order and they're the right ones. This is really screwy. =/
query = "SELECT [id],[ProductNum],[PartName],[Flag] FROM products WHERE ProductNum LIKE '%" & search & "%' ORDER BY '" & order_by & "' " & order

Share this post


Link to post
Share on other sites
Quote:
Original post by chbrules
I finally found out the problem. Don't use single quotes for the column name in the ORDER BY. I hate ASP if not SQL. =/


It's neither ASP or SQLs fault. You where sorting by a literal constant (a string) instead of by a column. Don't blame a language because you don't understand the basics.

Share this post


Link to post
Share on other sites
Quote:
Original post by Michalson
Quote:
Original post by chbrules
I finally found out the problem. Don't use single quotes for the column name in the ORDER BY. I hate ASP if not SQL. =/


It's neither ASP or SQLs fault. You where sorting by a literal constant (a string) instead of by a column. Don't blame a language because you don't understand the basics.


Seconded.

I was writing the exact same thing before I noticed you had posted it.

Share this post


Link to post
Share on other sites
I meant I hate the syntax of it all. Working between like 10 languages (web and programming), I jumble things up sometimes. I had just been stuck on that for a while until I ran a query through my enterprise manager and fiddled w/ the syntax.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this