为什么程序中执行到cmd.Execute语句时时提示至少一个参数没有设置
程序代码Private Sub Cmd_OK_Click()
'判断输入的用户名和密码是否符合标准
If Trim(txtUserName) = "" Then
MsgBox "请输入用户名"
txtUserName.SetFocus
Exit Sub
End If
If Len(txtPass) < 6 Then
MsgBox "密码长度不能小于6"
txtPass.SetFocus
txtPass.SelStart = 0
txtPass.SelLength = Len(txtPass2)
Exit Sub
End If
If txtPass <> txtPass2 Then
MsgBox "密码和确认密码不相同,请重新确认"
txtPass2.SetFocus
txtPass2.SelStart = 0
txtPass2.SelLength = Len(txtPass2)
Exit Sub
End If
'判断用户名是否已经存在
'如果是插入新的用户,则必须进行判断;如果是修改已有的用户,则当用户名被修改时进行判断
With MyUser
If Modify = False Or OriUser <> Trim(txtUserName) Then
If .In_DB(txtUserName) = True Then
MsgBox "用户名已经存在,请重新输入"
txtUserName.SetFocus
txtUserName.SelStart = 0
txtUserName.SelLength = Len(txtUserName)
Exit Sub
End If
End If
.UserName = Trim(txtUserName)
.UserPwd = Trim(txtPass)
'根据变量Modify的值决定是插入新数据,还是更新已有的数据
If Modify = False Then
.Insert
MsgBox "添加成功"
Else
.Update (OriUser)
'如果修改自身用户名,则更新CurUser对象
If OriUser = CurUser.UserName And Trim(txtUserName) <> OriUser Then
CurUser.UserName = Trim(txtUserName)
CurUser.GetInfo (CurUser.UserName)
End If
MsgBox "修改成功"
End If
End With
Unload Me
End Sub
标准模块代码:
'执行数据库操作语句
Public Sub SQLExt(ByVal TmpSQLstmt As String)
'创建Command对象cmd
Dim cmd As New
'连接到数据库
DB_Connect
'设置cmd的ActiveConnection属性,指定与其关联的数据库连接
Set cmd.ActiveConnection = cnn
'设置要执行的命令文本
= TmpSQLstmt
'MsgBox TmpSQLstmt
'执行命令
cmd.Execute
'清空cmd对象
Set cmd = Nothing
'断开与数据库的连接
DB_Disconnect
End Sub
user类代码:
Public Sub Update(ByVal TmpUser As String)
SqlStmt = "Update Users Set UserName='" + Trim(UserName) _
+ "',UserPwd='" + Trim(UserPwd) + "' WHERE UserName='" _
+ Trim(TmpUser) + "'"
SQLExt (SqlStmt)
End Sub