Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change order by in a selectcommand using parameters

Status
Not open for further replies.

stinkybee

Programmer
May 15, 2001
218
GB
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
 

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top