新零售与顾客关系:VB中的一个实时错误~请大家进去看看实时错误(8004d00e)试着不先使用BeginTrans而提交或退回事务

来源:百度文库 编辑:中科新闻网 时间:2024/04/28 20:00:59
Private Sub cmdModify_Click()
Dim intRespond As Integer
Dim strSql As String
On Error GoTo errorHandle
If Trim(txtPassNew.Text) <> Trim(txtPassNewR.Text) Then
intRespond = MsgBox("您的密码输入不正确", 5, "警告")
If intRespond = vbRetry Then
txtPassNew.Text = ""
txtPassNewR.Text = ""
txtPassNew.SetFocus
Exit Sub
End If
End If
gMainConn
Dim adoQry As adodb.Recordset
Set adoQry = New adodb.Recordset
strSql = "select count(*) from user where userName=" & "'" & Trim(txtName.Text) & "'" & "and passWord=" & "'" & Trim(txtPass.Text) & "'"
adoQry.Open strQry, gCn, adOpenStatic, adLockOptimistic
If adoQry.Fields(0).Value < 1 Then
MsgBox "您无权修改次密码", , "警告"
adoQry.Close
Set adoQry = Nothing
Exit Sub
End If
Dim adoCmdUpdate As New adodb.Command
strSql = "update user set passWord=" & "'" & Trim(txtPassNew.Text) & "'where userName='" & Trim(txtName.Text) & "'"
Set adoCmdUpdate.ActiveConnection = gCn
adoCmdUpdate.CommandType = adCmdText
adoCmdUpdate.CommandText = strSql
gCn.BeginTrans
adoCmdUpdate.Execute
gCn.CommitTrans
MsgBox "密码修改成功", , "提示"
Exit Sub
errorHandle:
gCn.RollbackTrans
MsgBox "修改密码不成功!可能此用户已经存在", , "警告"
End Sub

老报错~:实时错误(8004d00e)试着不先使用BeginTrans而提交或退回事务