SQL to Query text in access with an apostrophe in it

后端 未结 5 1003
你的背包
你的背包 2020-12-14 00:33

Please help me with this because I cannot seem to get it right

I am trying to query a name(Daniel O\'Neal) in column names tblStudents in an access database however

5条回答
  •  不知归路
    2020-12-14 01:17

    ...better is declare the name as varible ,and ask before if thereis a apostrophe in the string:

    e.g.:

    DIM YourName string

    YourName = "Daniel O'Neal"

      If InStr(YourName, "'") Then
          SELECT * FROM tblStudents WHERE [name]  Like """ Your Name """ ;
       else
          SELECT * FROM tblStudents WHERE [name] Like '" Your Name "' ;       
      endif
    

提交回复
热议问题