INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Change order by in a selectcommand using parameters

Change order by in a selectcommand using parameters

(OP)
I am trying to change an ORDER BY in my SelectCommand of an AccessDataSource.

I have tried using a QueryStringParameter to get a value and then add

"ORDER BY @orderby DESC"

but that doesn't work. I have also tried using a FilterExpression with a QueryStringParameter like this

FilterExpression="ORDER BY {0} DESC"

but that also gives an error

So, what I need is to be able to sort my data by changing the ORDER BY of my select command with a value obtained from a QueryString. I thought this would be fairly simple to achieve but half a day and hundreds of searches later I am still no closer. Any help would be appreciated.

Web Development Manager
http://www.freemoneyoff.co.uk
http://www.freemoneyresource.co.uk
http://www.freemoneysurveys.co.uk

RE: Change order by in a selectcommand using parameters


I do not know Access, but in SQL a stored procedure would look like this :


DECLARE @Statement nvarchar(255)

Set @Statement = 'SELECT * FROM [THISTABLE] ORDER BY [' + @Orderby + ']'

EXEC @Statement


Where @orderby is a parameter for the sp
Maybe this can be applied somehow to Access or at least give you a hint on what to do

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close