| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1728 人关注过本帖
标题:为什么程序中执行到cmd.Execute语句时时提示至少一个参数没有设置
只看楼主 加入收藏
zhangl7325
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2013-2-20
结帖率:33.33%
收藏
已结贴  问题点数:20 回复次数:6 
为什么程序中执行到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
搜索更多相关主题的帖子: 确认密码 用户名 
2013-03-06 13:37
Artless
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:4211
专家分:28888
注 册:2009-4-8
收藏
得分:10 
OriUser=?

无知
2013-03-06 13:46
zhangl7325
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2013-2-20
收藏
得分:0 
Public Modify As Boolean
Public OriUser As String

Private Sub Cmd_Cancel_Click()
  Unload Me
End Sub

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
2013-03-06 13:47
zhangl7325
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2013-2-20
收藏
得分:0 
Private Sub Cmd_Modi_Click()
  '如果没有选择用户名,则返回
  If DataList1.Text = "" Then
    MsgBox "请选择要修改的用户"
    Exit Sub
  End If
  '把当前用户的数据赋值到FrmUserEdit窗体的相关位置
  With FrmUserEdit
  .OriUser = MyUser.UserName
  .txtUserName = MyUser.UserName
  .txtPass = MyUser.UserPwd
  .txtPass2 = MyUser.UserPwd
  '如果当前用户为Admin,则不能修改用户名
  If Format(MyUser.UserName, "<") = "admin" Then
    .txtUserName.Enabled = False
  End If
  '将变量Modify设置为True,表示当前状态为修改已有数据
  .Modify = True
  '启动窗体FrmUserEdit
  .Show 1
  End With
  '刷新用户名列表框
  AdoUserList.Refresh
  DataList1_Click
End Sub
2013-03-06 13:49
zhangl7325
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2013-2-20
收藏
得分:0 
是不是
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
中的update有问题,或者
'执行数据库操作语句
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
有问题,但删除命令和插入命令都可以,就是更新提示错误
2013-03-06 14:02
zhangl7325
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2013-2-20
收藏
得分:0 
发现了,数据库的一个字段错了
2013-03-06 15:22
qq372505855
Rank: 2
等 级:论坛游民
帖 子:42
专家分:46
注 册:2012-6-20
收藏
得分:10 
楼主问,楼主又答。。。粗心问题,不过看了半天也不知道这是啥程序
2013-03-06 20:35
快速回复:为什么程序中执行到cmd.Execute语句时时提示至少一个参数没有设置
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015438 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved