各位老师:请问sql语句中要提交含有标点的文本数据如何写?由于含有标点,sql语句报错
例如:
          Dim strText as String = "你好,'张三'!你经常来<CSDN>论坛么?"
dim strSQL as String
strSQL = "INSERT INTO `Table` " & _
         "VALUES ('" & strText & "')"
这样的语句中由于里面含有,'!<>?等标点符号。在提交语句的时候肯定报错。请问遇到这种问题应当如何处理?谢谢各位!

解决方案 »

  1.   

    \'  A single quote (“'”) character mysql> SELECT 'hello', '"hello"', '""hello""', 'hel''lo', '\'hello';
    +-------+---------+-----------+--------+--------+
    | hello | "hello" | ""hello"" | hel'lo | 'hello |
    +-------+---------+-----------+--------+--------+
    Dim strText as String = "你好,'张三'!你经常来<CSDN>论坛么?"
    dim strSQL as String
    strSQL = "INSERT INTO `Table` " & _
             "VALUES ('" & replace(strText,"'","\'" & "')"
      

  2.   

    \0  An ASCII 0 (NUL) character. 
    \'  A single quote (“'”) character. 
    \"  A double quote (“"”) character. 
    \b  A backspace character. 
    \n  A newline (linefeed) character. 
    \r  A carriage return character. 
    \t  A tab character. 
    \Z  ASCII 26 (Control-Z). See note following the table. 
    \\  A backslash (“\”) character. 
    \%  A “%” character. See note following the table. 
    \_  A “_” character. See note following the table.