- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 .vbs 文件中调用 AddNew 和 Update 后尝试编辑 ADO RecordSet 记录的字段时,我收到错误消息“无法确定新插入的行的标识”。但是,我能够访问从数据库返回的主键。
我不是在寻找解决方法(例如关闭记录集并通过其 ID 检索记录),我只是真的很想了解为什么会发生此错误。我已经在测试文件中简化了我的代码以排除任何其他问题。您在下面看到的是我正在执行的确切代码,不包含任何文件(我已经从连接字符串中删除了凭据)。
Dim connString : connString = "Provider=SQLOLEDB.1;Persist Security Info=True;Data Source=localhost;Initial Catalog=;User Id=;Password="
Dim conn, rsTaskLog, sSQL
Set conn = CreateObject("ADODB.Connection")
conn.Open connString
' Create a new task log entry.
Set rsTaskLog = CreateObject("ADODB.Recordset")
sSQL = "SELECT * FROM Test"
rsTaskLog.Open sSQL, conn, 1, 3, 1 'adOpenKeyset, adLockOptimistic, adCmdText
rsTaskLog.AddNew
rsTaskLog.Update
' Set the task log result.
rsTaskLog.Fields("test_int").Value = 1 ' Error occurs on this line.
rsTaskLog.Update
rsTaskLog.Close
Set rsTaskLog = Nothing
更新:
我能够通过在第一次更新后添加以下行来使此代码正常工作:
rsTaskLog.AbsolutePosition = rsTaskLog.AbsolutePosition
关于移动当前记录的一些事情是将 RecordSet 放回到可以编辑的状态(MoveLast 和 MoveFirst 也有效)。任何人都知道导致这种情况的幕后发生了什么?
最佳答案
我想出的解决方案是在 RecordSet 上调用第一个 Update 后立即添加以下代码行:
rsTaskLog.AbsolutePosition = rsTaskLog.AbsolutePosition
出于某种原因,移动光标位置会使 RecordSet 回到可以再次调用 Update 而不会产生错误的状态(MoveFirst 和 MoveLast 也有效,但通过将 AbsolutePosition 设置为自身,我们能够保持当前位置).我不完全确定这里的幕后发生了什么,如果您知道,请随时在评论中详细说明。
关于vbscript - "Identity cannot be determined for newly inserted rows"在 ADO RecordSet AddNew 和 Update 之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31061584/
我很难找到正确的搜索语法:) 作为作业的一部分,我正在为 Android 开发一个国际象棋游戏。 我想使用按钮。 我画了棋盘,可以选择一个按钮(即我要移动的棋子)。 我可以点击一 block (按钮)
我有两个类,一个依赖于硬件,一个不依赖于硬件(我们分别称它们为 HardwareDependent 和 HardwareIndependent)。硬件相关类扩展了硬件独立类。现在我有另一个类,它至少必
在这里得到一个 Hibernate MappingException,我不知道为什么。 这是我得到的错误: 2014/01/13 23:58:38 [] ERROR GrailsContextLoad
我想了解 RODBC 如何确定新创建的 (Access) 表的列类型? sqlSave 的 R 文档非常神秘:“类型是通过咨询参数 varTypes 和 typeInfo 来选择的”。并且没有这个论点
我有一个具有定义高度的 div,并且 overflow:scroll; 。它的内容太长,因此出现滚动条。 现在是发痒的部分。它的一些内部 HTML 总是奇怪地出现(准确地说,是 tableFilter
场景 某些 SQL 代理作业计划全天每隔几分钟运行一次。 在某些情况下,它会错过下一个计划,因为它仍在按照上一个计划运行。 每隔一段时间,作业可能会“挂起”。这不会产生失败(因为作业尚未停止)。发生这
目前我使用这个解决方案来加载资源: URL url = MyClass.class.getClassLoader().getResource("documents/"+path); if(url ==
我正在尝试使用nRoomAllocationId在房间传输和房间部门映射类上实现多对一和一对多双向映射。 房间转移类 @Entity @Table(name="roomtransfer") publi
我有一个来自类的 print 方法: public void print(EditorPanePrinter epp) { try { PrinterJob pj=Printe
确定文件所在目录的好方法是什么?我会使用 realpath(),但这会返回符号链接(symbolic link)指向的文件或目录的绝对路径。 例如,如果参数是文件的基名,并且 lstat() 返回 0
我有一个名为 account 的抽象类,如下所示 - abstract class Account { private int number; private String owner
我一直在编写一个打开 Firebird 数据库的小型 Python 应用程序。 为了实现此目标,我使用嵌入的 Firebird 2.5.7.27050,64 位。 尽管如此,无论何时我尝试使用 Pyt
我有一个非常有趣的(至少对我而言)问题要解决(而且,不,这不是家庭作业)。它等同于:您需要确定用户在他的计算机前进行的“ session ”和“ session 开始和结束时间”。 您将获得进行任何用
从 iOS8 开始,您需要注册并提示用户使用本地通知。因此,我想实现一种方法来仔细检查这些权限。 如何检查本地通知设置是否未确定/未设置?到目前为止,我只知道如何检查本地通知是否被granted 或d
在我的应用程序中,我使用 Google In-app Billing Version 3 API 实现应用内购买。在我的应用程序的日志中,我看到: D/Finsky (26024): [1204]
我的小部件有几个 ImageButtons,为它们设置 onClicked 事件,我使用 PendingIntent: Intent intent = new Intent(context, Upda
推送到 github 工作正常。我认为当我从 github checkout 一个分支时,这个问题就开始了。我该如何解决?当我现在尝试推送到 github 时,出现错误“无法确定当前分支。” 此外,我
我正在尝试使用表数据导入向导工具将一个 csv 文件导入到我的数据库中,导入到只有一个属性(它的 ID VARCHAR(10))的表中,导入失败并向我显示此错误:error我检查了 csv 文件以查找
我正在尝试将一些随机生成的数字“合并”在我之前拥有的值向量中的相邻值之间定义的间隔之间。所以基本上,我有以下几点: vectorA包含从 101 到 0 的 101 个值。 我生成一个名为 x 的随机
我要执行一个脚本file.R使用 Rscript .在 file.R ,我使用包dplyr . # file.R df outputFile.Rout 2>&1 但是,如果我添加 default-p
我是一名优秀的程序员,十分优秀!