CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: String Question

  1. #1
    Join Date
    Mar 2001
    Location
    Israel
    Posts
    116

    String Question

    Hi

    I have a basic question
    I am using SQL command/query like
    "INSERT INTO table1 (FName) VALUES (' " & sStr & " ' )"
    If sStr (the string) contain the char " ' " then I get an error
    I understand why it happened but I need a way around it

    Thanks
    Limor

  2. #2
    Join Date
    Jan 2003
    Location
    Amsterdam, Netherlands
    Posts
    97
    If a string that has to be insert or update into a database countains any single '
    you have to double them to 2 single ' , so the database knows it is a character of the string and not of the whole sql-statement.

    Add the following line just before you put the whole sql-statement together.

    sStr = sStr.Replace("'", "''")

  3. #3
    Join Date
    Dec 2002
    Location
    USA
    Posts
    207
    Yes the old DoubleQuote Problem

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured