Results 1 to 6 of 6

Thread: The ' character

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Santo Domingo,D.N., Dom. Rep.
    Posts
    707

    Talking The ' character

    My field is nvarchar on SQL 2000 but when i typed a name with ' i got an error, how can i avoid this error?

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    entering? or searching? for the data
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    First, you have to tell SQL Server to allow quoted identifier.
    Code:
    Conn.Execute "SET QUOTED_IDENTIFIER ON"
    When inserting your data, you have to substitue each single quote with 2 single quotes:
    Code:
    Conn.Execute "Insert Into MyTable (MyField) Values ('" & Replace(MyValue, "'", "''") & "')"

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Santo Domingo,D.N., Dom. Rep.
    Posts
    707
    Entering Data, geoff_xrx

    Serge: That look find, but what happen when searching?

  5. #5
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Same thing - you just change the SQL stuff.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You have set the quoted identifier on again, before running a select statement.

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