求助,UpdateBatch adAffectCurrent问题(80040E21)
Sub OpenADOConnection()Dim Connect As String
Dim Msg As String
Dim afp As String
Dim GBServer As String
Set cn = New ADODB.Connection
afp = App.Path & AccessFile
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & afp & ";Persist Security Info=False;"
' = 120 'change from default 30 sec to 120 sec
'cn.ConnectionTimeout = 60 'change from default 15 sec to 60 sec
cn.ConnectionString = Connect
cn.Open
Exit Sub
End Sub
Sub DeletePstock()
Dim cmd As String
Dim Rserder As ADODB.Recordset
Set Rserder = New ADODB.Recordset
OpenADOConnection
Rserder.Open "select * from Pstock", cn, adOpenKeyset, adLockBatchOptimistic
Rserder.MoveFirst
If Rserder.Fields!OrderNo <> "" Then
Do While Not Rserder.EOF
Rserder.Delete adAffectCurrent
Rserder.UpdateBatch adAffectCurrent
Rserder.MoveNext
Loop
End If
代码如上,显示错误80040E21,多步 OLE DB 操作产生错误。如果可能,请检查每个 OLE DB 状态值。没有工作被完成。 请教,这个问题到底是怎么一回事,谢谢!!