使用 sql 保留字作为列更新 (ado) 记录集

Update (ado) recordset with sql reserved word as a column

我正在执行以下代码:

Set cmdTemp = Server.CreateObject("ADODB.Command")
cmdTemp.CommandType = adCmdText
...
cmdTemp.CommandText = "SELECT email, [Identity], UserName, UserId " & _
                      "  FROM Users WHERE UserId = '" & UserId & "'"

rst.Open cmdTemp, ,adOpenForwardOnly ,adLockOptimistic
rst("Identity") = "101" //ERROR!
rst.Update
rst.Close

它给出了这个错误:

ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.

/iweb/admin/Users.asp, line 2118

我的理解是因为在 SQL 服务器中保留了 Identity 一词,但无法使其正常工作。

还尝试替换抛出错误的行:

rst("[Identity]") = "101"

结果是:

ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.

/iweb/admin/Users.asp, line 2118

尝试用 adOpenKeyset CursorTypeEnum

打开记录集

找例子here