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

  • SEARCH
  • Home
  • 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 8596119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:36:04+00:00 2026-06-12T00:36:04+00:00

We have some classic ASP pages that connect to a MS SQL server database.

  • 0

We have some classic ASP pages that connect to a MS SQL server database. To prevent SQL injection, we just replace all single quotes with a double single quote. This seems to be the method prescribed here: https://web.archive.org/web/20211020150656/https://www.4guysfromrolla.com/webtech/061902-1.shtml

This still feels dangerous to me. Is there any way to escape the single quote with any other character, potentially opening up the SQL Injection?

EDIT:) We currently have a lot of old code that uses this single quote to double single quote replacement. If that is sufficient to prevent SQL injection, then we won’t change anything. My real question is if this method insecure.

  • 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-12T00:36:05+00:00Added an answer on June 12, 2026 at 12:36 am

    Use a parameterized query. If you don’t use concatenation to glom your SQL statements together, the single quotes are taken care of for you. Example:

    Set objCommand = CreateObject("ADODB.Command")
    With objCommand
    .CommandText = "INSERT dbo.Table(Column) values (?)"
    .CommandType = adCmdText
    .ActiveConnection = "Connection string" or existing open connection
    .Parameters.Append .CreateParameter("@p1", adVarChar, adParamInput, 50, "O'Brien")
    .Execute
    Set .ActiveConnection = Nothing
    End With
    

    The method you’re currently relying on is not secure. Let’s say you have the following dynamic SQL embedded in your ASP page:

    sql = "SELECT Name FROM dbo.Students WHERE Id = " & Request("StudentId") 
    

    Now let’s say someone decided to try to jam the following into the querystring (or form, or what have you):

    1; DROP TABLE dbo.Students;
    

    How does replacing this string with single quotes help you avoid SQL injection? In cases where you know, you could potentially do:

    sql = "SELECT Name FROM dbo.Students WHERE Id = " & CLng(Request("StudentId"))
    

    So now you have to go in and re-write this code anyway, and find cases where the data type that is opening you up to injection isn’t a string.

    SQL injection is not defined solely by exploiting single quotes. There are probably a dozen other ways to do this depending on how you are constructing your SQL strings. If you want to feel safe by just protecting those cases, that’s up to you. I wouldn’t. I would properly parameterize all queries with type safety. Eliminates all the issues and you will sleep better at night even though the up-front cost may be large.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have some Classic ASP pages that produce all output via Response.Write.
I have a .NET solution that works together with some classic ASP pages, as
I have a Classic ASP site, that requires some database tables to be emptied
We have a classic ASP site that has some pages that do some extreme
I have a classic ASP page that calls in some other ASP files using
I have just moved a customer's Classic ASP website to their own VPS server
What I am trying to do is simple. I have some Classic ASP with
I have a classic ASP application which inserts some values into a word file
I have a DataSet with some DataTables that are linked together with DataRelations (classic
I have a legacy web-site that I am maintaining (built mostly in classic ASP

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.