Quotes in SQL

Results 1 to 2 of 2

Thread: Quotes in SQL

  1. #1
    Join Date
    Dec 1969

    Default Quotes in SQL

    I have a form that posts a string to another asp page. If the user types a single quote (&#039) such as Bob&#039s Business, the SQL INSERT statement generates an error because of the single quote. An asp book I have suggests running the string through a function to remove the quote. I can&#039t believe that this is the only solution. Does anyone know how to insert a string with a single quote into a database using ADO/SQL???? I&#039ve written similar code using ColdFusion and it works fine (probably because ColdFusion somehow "escapes" the quote). I&#039m fairly new to asp and I can&#039t believe how much more difficult it is to do simple database interaction than with ColdFusion!!! Any help would be greatly appreciated!<BR><BR>Thanks<BR>- Byron

  2. #2
    Join Date
    Dec 1969

    Default RE: Quotes in SQL

    it&#039s relatively simple, but you need to duplicate the single quote (&#039) mark... This will then work..<BR><BR>Using the REPLACE function it can be done easily....<BR><BR>replace(request("fieldname"),"&# 039","&#039&#039") <BR><BR>This will work fine..<BR><BR>CWC.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts