本人所用数据库:ORACLE9i
功能:点击新增按钮,填写信息,再点击保存。
但点击保存后出现错误:实时错误 '-2147217887 (80040e21)':多步操作产生错误。请检查每一步的状态值。
代码如下:
Dim Conn As New ADODB.Connection '连接变量
Dim Connstring As String '连接字符串
Dim RS1 As New ADODB.Recordset '记录集变量
Dim bm '定义一个变量用来存放添加记录时原来记录的位置
Dim tj As Boolean
Private Sub Form_Load()
C
With Conn
.ConnectionString = Connstring
.ConnectionTimeout = 10
.Open
End With
RS1.CursorType = adOpenDynamic
RS1.CursorLocation = adUseClient
RS1.LockType = adLockOptimistic
RS1.Open "加班记录表", Conn, adOpenForwardOnly, , adCmdTable
Adodc1.Visible = False
End Sub
Private Sub Command1_Click() '新增加班
bm = Adodc1.Recordset.Bookmark '用书签记下当前记录位置
Adodc1.Recordset.AddNew '调用AddNew方法增加新记录
tj = True '是添加新记录
Command1.Enabled = True
Command2.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
End Sub
Private Sub Command7_Click() '保存
Adodc1.Recordset.Update '调用Update方法保存
Adodc1.Refresh
MsgBox ("保存成功") '给出保存成功提示
End Sub