Jump to content
  • Advertisement
Sign in to follow this  
chbrules

[ASP] Query problems

This topic is 4882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
What are the actual values of order_by and order? What happens if you replace them with explicit values directly in the query? How are the records being arranged, and how is that different from the result you are trying to achieve?

Share this post


Link to post
Share on other sites
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. =/

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!