CSDN博客

img dingxy

SQL statement 中由单引号时

发表于2008/9/29 16:36:00  438人阅读

q:
     I got an error with following sql statement:
    "update Group set name = 'q's' where ID =2",
    it seems i can't use " ' " within value update command, right??
    wish get your great help!(QING CHEN)
 
a:
    在Sql语句中,如果包括单引号(“ '”)那么必须将其转化成两个单引号(“''”),否则就 会出错。所以这条语句应该这样:
     "update group set name='q''s' where id=2"

     Public Function StrToSQL(ByVal strValue As String) As String
     StrToSQL = "'" + Replace(strValue, "'", "''") + "'"
    End Function
==============================
supplierName.replace("'", "''")
0 0

相关博文

我的热门文章

img
取 消
img