Problem with fields with single and double quotes in SQL statements 
Author Message
 Problem with fields with single and double quotes in SQL statements

I need to know how you can write an SQL UPDATE statement where the fields in
the WHERE clause have single or double quotes (',").  The SQL statement I
have written so far is:

    MainDB.Execute "UPDATE BookingSourceLookup SET WROBookingSource = '" &
rs2!WROBookingSource & "', PMSBookingSource = '" & _
         rs2!PMSBookingSource & "', Description = '" & rs2!Description & "'
WHERE WROBookingSource = '" & rs2!WROBookingSource & "'"

Since all the fields in this statement are strings, they need to be
surrounded by single quotes(') for them to work.  This is fine until one of
these string fields contains a single or double quote.  When this happens
the program craps out.  Does somebody know how to get around this without
limiting the user to not entering single or double quotes into their fields.

Thanks in advance,
Rick.



Sat, 13 Apr 2002 03:00:00 GMT
 Problem with fields with single and double quotes in SQL statements

Quote:
>Does somebody know how to get around this without
>limiting the user to not entering single or double quotes into their fields.

Strings can have embedded quotes if they're doubled up (e.g. ' as '').  The
extra quote doesn't show up in the result.  A simple replace algorithm can
handle this conversion without adding much time to the query execution.


Sun, 14 Apr 2002 03:00:00 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. Problem with SINGLE and DOUBLE quote in T-SQL statement

2. Single-quote and double-quote characters in fields

3. Handling single and double quotes in one SQL statement

4. Single/Double quote for string field in SQL

5. Single/Double quote for string field in SQL

6. bulk insert statement - single or double quotes

7. help: double quote vs. single quote string delimiter

8. rules of single quotes and double quotes

9. saving data with single quote or double quote

10. SQL Statement - Double Quotes problem

11. Single/Double Quote Problems with ODBC

12. single quote problem with SQL statement


 
Powered by phpBB® Forum Software