Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8246087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:23:38+00:00 2026-06-07T22:23:38+00:00

I am using classic ASP with a parameterized SQL querystring as follows: SQL =

  • 0

I am using classic ASP with a parameterized SQL querystring as follows:

SQL = "SELECT * FROM content WHERE Category LIKE ? ORDER BY SubDate ?"

The SQL query string is being used in the following parameterized code:

Set cmd = Server.CreateObject("ADODB.Command")
Set rsView = Server.CreateObject("ADODB.Recordset")
cmd.ActiveConnection = MM_connContent_STRING
cmd.Prepared = true
cmd.CommandType = adCmdText
cmd.CommandText = SQL
cmd.CommandTimeout = 60

cmd.Parameters.Append(cmd.CreateParameter("Category", 202, adParamInput, 30, qFilter))
cmd.Parameters.Append(cmd.CreateParameter("SubDate", 202, adParamInput, 10, myDateSort))

rsView.CursorLocation = adUseClient
rsView.Open cmd, , adOpenForwardOnly, adLockReadOnly

The code above works great except for one huge problem. The “ORDER BY SubDate ?” part outputs “ORDER BY SubDate ‘DESC'” where DESC has single quotes around it added due to the fact that it is a parameter. I get a bad syntax error when running the code above because of the single quotes around DESC (which can also be ASC depending on what the user selects and sends through the URL query string). It seems all SQL parameters are output with single quotes. How can I remove the single quotes from specific SQL parameters so they don’t create syntax errors in the SQL string?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:23:39+00:00Added an answer on June 7, 2026 at 10:23 pm

    It is very uncommon to allow keywords (or identifiers for that matter) to be parameters. There is not a single framework that I know of that supports it.

    Since there are only 2 allowable values, why don’t you simply write:

    SQL = "SELECT * FROM content WHERE Category LIKE ? ORDER BY SubDate "
    If myDateSort = "ASC" Or myDateSort = "DESC" Then
        SQL = SQL & myDateSort
    Else
        'whoops, value not allowed. raise error... 
    End If
    '...rest of your code... 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using classic asp, I am trying to query a SQL Server database like so:
I'm trying to update an NText field in SQL 2000 using Classic ASP. Here
I'm working on an ASP (Classic) application using MS SQL as database. In the
When writing parameterized queries in Classic ASP, I have been using the following syntax:
I am using Classic asp and SQL Server 2005. This is code that works
I'm using asp code i.e classic ASP and SQL server 2000 in this process
I am converting my classic asp to .Net using parameterized queries. My problem is
I am in need of using classic ASP to create an XML file from
I need to get the Windows domain name from Internet Explorer using classic asp
When using CAPICOM in Classic ASP (VBScript) to perform MD5 hashing like so: With

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.