ASP 101 - Active Server Pages 101 - Web01
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

 Top ASP 101 Stories Top ASP 101 Stories
An Overview of ASP.NET
Connections, Commands, And Procedures
What is ASP?

Don't Forget that Final /
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates

Quick Tips

Using Quotes in Your SQL Commands

SQL uses a single quote (') character to mark the beginning and end of a string. As such, using a string that contains a quote can cause errors because your database thinks the string is finished and expects SQL commands to come immediately after it.

In order to get around this problem, when SQL encounters two quotes in a row, it translates them into a single quote and continues reading the string instead of interpretting the quote as a string delimiter.

Note: This is the exact same behavior VBScript uses to deal with the double quote (") as illustrated in this tip.

To easily deal with this problem you can utilize a simple function like the one that follows to automatically double up your quote characters before passing your string to the SQL parser.

Function DoubleUpSingleQuotes(strInput)
    DoubleUpSingleQuotes = Replace(strInput, "'", "''")
End Function

Previous      Show All Tips      Next

If you have a tip you would like to submit, please send it to:

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers