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 6605935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:20:32+00:00 2026-05-25T19:20:32+00:00

I have a web-form with a Name field which I want to be able

  • 0

I have a web-form with a Name field which I want to be able to accept single apostrophes, such as in the name O’Leary, but when trying to push this record to the SQL 2005 server, I get an error. My question is not this. It’s that when I attempt to insert the record into the db using this statement…

Dim acctName As String = Replace(txtName.Text, "'", "''")

I get O”Leary in the database instead of O’Leary. Thought SQL was supposed to treat these double single apostrophes as one apostrophe???

  • 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-05-25T19:20:33+00:00Added an answer on May 25, 2026 at 7:20 pm

    You’d be better off using parameterized queries. These will automatically handle the single quotes, and protect you better from SQL Injection.

    Inserting the double single quotes (did I say that right?) is a way of escaping the data. It should work, but it’s not a best practice.

    See this article for a much fuller answer:

    http://msdn.microsoft.com/en-us/library/ff648339.aspx

    What I’m proposing is step 3.

    Edit – I should read the question better

    If you’re already using parameterized queries, or a stored procedure, and you’re setting the value of acctName to the value of a parameter, then you do not need to escape the quotes yourself. That’s handled automatically.

    It’s also handled by several tools, including the Mirosoft Patterns and Practices Database library. That has several commands where you can pass in a statement and array of objects that are used as parameter values -that handles the escaping as well.

    If either of those are the case, you can completely eliminate the line of code where you’re replacing the values.

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

Sidebar

Related Questions

I have a web form to which I want to take a parameter from
I have web form with a panel which has form elements in side it.
I have a web form where I have a textbox in which the user
I have a web form that has 2 radio buttons, depending on which one
I have an asp web form which is used for database entry located at
I want to build a back end of a general web form which contains
I don't code in PHP, but I have this form which I pulled off
I have a registration form which displays a users Name (textbox), Email (textbox) and
I have two web pages which work basically the same, code-wise, but one of
I have URLs of the form http://domain/image/⟨uuid⟩/42x42/some_name.png . The Web server (nginx) is configured

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.