Quotation marks in SQL

Results 1 to 3 of 3

Thread: Quotation marks in SQL

  1. #1
    Dylan Towns Guest

    Default Quotation marks in SQL

    I have an ASP page that posts information to a database via an SQL INSERT statement, I have a problem whereby when a customer uses a Quotation mark in the text I get the followinmg error <BR>ODBC_Microsoft_Access_97_Driver]_Syntax_error_(missing_operator)_in_query_expressi on...<BR>as it is taking the quotation mark as the end of the string. how can I change the code to check it the quotation mark is part of the customers text or the SQL statement?

  2. #2
    Join Date
    Dec 1969

    Default RE: Quotation marks in SQL

    What I normally do to fix that problem is write a little checkString function on the user&#039s data, like so:<BR><BR>Function ChkString(string)<BR> if string = "" then string = " "<BR> ChkString = Replace(string, "&#039", "&#039&#039")<BR>End Function<BR><BR>i.e.<BR><BR>correctedStr = ChkString(request.form("new_data"))<BR>strSql = "insert into tablename (new_data) values (&#039"&correctedStr&"&#039)"<BR><BR>Or something like that.<BR><BR>Hope this helps.<BR><BR>Ben

  3. #3
    Join Date
    Dec 1969

    Default RE: Quotation marks in SQL

    Thanks a lot Ben, that works great<BR><BR>Dyls

Posting Permissions

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