Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server “替换错误”;800a005e";在记录集中_Sql Server_Ms Access_Asp Classic - Fatal编程技术网

Sql server “替换错误”;800a005e";在记录集中

Sql server “替换错误”;800a005e";在记录集中,sql-server,ms-access,asp-classic,Sql Server,Ms Access,Asp Classic,我有一个功能齐全的网站,运行的是access数据库,所以我决定升级MSSQL,结果比其他时候更难 我有一个名为800a005e的错误 这是我的职责: 函数转义特殊字符(ByVal strRSContent) strRSContent=替换(strRSContent,“&”、“&;”) strRSContent=替换(strRSContent,“É”和“É;”) strRSContent=替换(strRSContent,“é”、“é;”) strRSContent=替

我有一个功能齐全的网站,运行的是access数据库,所以我决定升级MSSQL,结果比其他时候更难

我有一个名为800a005e的错误

这是我的职责:

函数转义特殊字符(ByVal strRSContent)
strRSContent=替换(strRSContent,“&”、“&;”)
strRSContent=替换(strRSContent,“É”和“É;”)
strRSContent=替换(strRSContent,“é”、“é;”)
strRSContent=替换(strRSContent,“Æ”和“Æ;”)
strRSContent=替换(strRSContent,“Ø”和“Ø;”)
strRSContent=替换(strRSContent,“Å”和“Å;”)
strRSContent=替换(strRSContent,“æ”和“æ;”)
strRSContent=Replace(strRSContent,“ø”和“ø;”)
strRSContent=替换(strRSContent,“å”和“å;”)
转义特殊字符=strRSContent
端函数
这就是我所说的乐趣:

如果不是isNull(strPageContent),则
响应。编写strPageContent
如果结束

请注意,当我在access数据库上使用它时,一切都正常工作,但现在情况不同了

有时alle IsEmpty、IsNull等会让人有点沮丧。。。我使用自定义函数来避免这些问题:

Public Function IsNullOrEmpty(strString)
  strString = Trim(strString)

  If IsEmpty(strString) Then
    IsNullOrEmpty = True
    Exit Function
  ElseIf StrComp(strString, "") = 0 Then
    IsNullOrEmpty = True
    Exit Function
  ElseIf IsNull(strString) Then
    IsNullOrEmpty = True
    Exit Function
  Else
    IsNullOrEmpty = False
    Exit Function
  End If
End Function

Function EscapeSpecialCharacters(ByVal strRSContent)
    If IsNullOrEmpty(strRSContent) Then
        EscapeSpecialCharacters = ""
        Exit Function
    End If

    strRSContent = Replace(strRSContent,"&","&")
    strRSContent = Replace(strRSContent,"É","É")
    strRSContent = Replace(strRSContent,"é","é")

    strRSContent = Replace(strRSContent,"Æ","Æ")
    strRSContent = Replace(strRSContent,"Ø","Ø")
    strRSContent = Replace(strRSContent,"Å","Å")
    strRSContent = Replace(strRSContent,"æ","æ")
    strRSContent = Replace(strRSContent,"ø","ø")
    strRSContent = Replace(strRSContent,"å","å")

    EscapeSpecialCharacters = strRSContent
End Function
因此,在您的情况下,无论DB:

Dim strPageContent
strPageContent = EscapeSpecialCharacters(RecSetPageContent("pagecontent"))

将函数更改为此,以处理输入为null时的情况:

Function EscapeSpecialCharacters(ByVal strRSContent)
    If IsNull(strRSContent) Then
        EscapeSpecialCharacters = ""
        Exit Function
    End If

    strRSContent = Replace(strRSContent,"&","&")
    strRSContent = Replace(strRSContent,"É","É")
    strRSContent = Replace(strRSContent,"é","é")

    strRSContent = Replace(strRSContent,"Æ","Æ")
    strRSContent = Replace(strRSContent,"Ø","Ø")
    strRSContent = Replace(strRSContent,"Å","Å")
    strRSContent = Replace(strRSContent,"æ","æ")
    strRSContent = Replace(strRSContent,"ø","ø")
    strRSContent = Replace(strRSContent,"å","å")

    EscapeSpecialCharacters = strRSContent
End Function

Access可能返回空字符串,而SQL Server返回Null。

我们不记忆错误代码。你能告诉我们错误信息的内容吗?另外,
strRSContent
的数据类型是什么?如何从数据库中填充该变量?为什么不使用HTMLEncode?对不起……这是个好主意;-)错误是这样的:Microsoft VBScript运行时错误“800a005e”无效地使用Null:“Replace”/includes/functions.asp,第7行,这是第一行Replace(strRSContent,“&”,“&;”),为什么不使用utf8编码。-认真地尝试通过替换值来避免编码不匹配,我现在已经看到了一切。这里是一个未来的提示
Response.CodePage=65001
Response.Charset=“UTF-8”
很抱歉我的回复太晚了!这并不是说它是空的,因为如果我为特定的pageid(或pagecontent)选择了我的metas,那么数据应该写入页面,但它不会。但是,如果我在MSSQL中进行相同的查询,则每个信息都会按其应有的方式进行选择。因此,问题不在于SQL(我没有任何包含“NULL”的字段)。@Daniel yes它是NULL,这是
Replace
引发此类错误的唯一方法。字段中不需要显式地包含null值,缺少任何其他值也是null。如果您将发布您的SQL,也许我可以帮助您更深入地跟踪它。对不起,我的回复太晚了!在我进入“If Not isNull(strPageContent)Then Response.Write strPageContent End If”之前,我有这样一句话:If RecSetPageContent(“pagecontent”)“那么strPageContent=EscapeSpecialCharacters(RecSetPageContent(“pagecontent”))由于某种原因是不允许的……可能是因为有换行符或代码(
/)吗?因为一个普通的“”没有问题…不,我不这么认为,这不是错误所暗示的,有些DB返回空的,有些是空的。您可以尝试将IsNull替换为IsEmpty或使用my函数。请参阅我的编辑。