标题:“添加用户”“删除用户”“修改密码”均出现同样的错误。
只看楼主
luojia86
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2008-4-6
结帖率:100%
 问题点数:0 回复次数:2 
“添加用户”“删除用户”“修改密码”均出现同样的错误。
Private Sub Command1_Click()
Dim sql As String
Dim rs_adduser As New ADODB.Recordset
Dim cn As New ADODB.Connection
cn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database.mdb"
 
 If Trim(Text1.Text) = "" Then
 
    MsgBox "用户名不能为空"
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text1.SetFocus
    Exit Sub
 Else
    sql = "select * from user where 1=1"
   
   rs_adduser.Open sql, cn, adOpenKeyset, adLockPessimistic
 
      While (rs_adduser.EOF = False)
         
         If Trim(rs_adduser.Fields(0)) = Trim(Text1.Text) Then
            MsgBox "已有这个用户,请重新输入"
            Text1.Text = ""
            Text2.Text = ""
            Text3.Text = ""
            Text1.SetFocus
            Exit Sub
            
        Else
           rs_adduser.MoveNext
        End If
        Wend
     If Trim(Text2.Text) <> Trim(Text3.Text) Then
        MsgBox "两次密码输入不一致,请重新输入", vbOKOnly + vbExclamation, "提示"
        Text2.Text = ""
        Text3.Text = ""
        Text2.SetFocus
        Exit Sub
     Else
        rs_adduser.AddNew
        rs_adduser.Fields(0) = Text1.Text
        rs_adduser.Fields(1) = Text2.Text
        rs_adduser.Update
        MsgBox "添加新用户成功", vbOKOnly + vbExclamation, "提示"
     End If
End If

        
End Sub

Private Sub Command2_Click()
Unload Me

End Sub
出错提示“from 子句语法错误”
提示错误在“rs_adduser.Open sql, cn, adOpenKeyset, adLockPessimistic”
搜索更多相关主题的帖子: quot 密码 Microsoft Dim sql 
2008-05-27 18:59
luojia86
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2008-4-6
得分:0 
“添加用户”“删除用户”“修改密码”均出现同样的错误。
Private Sub Command1_Click()
Dim sql As String
Dim cn As New ADODB.Connection
Dim rs_mima As New ADODB.Recordset
cn.Open "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\database.mdb"
  If Trim(Text2.Text) <> Trim(Text3.Text) Then
     MsgBox "两次密码不一致,请重新输入!", vbOKOnly + vbExclamation, "提示"
     Text2.Text = ""
     Text3.Text = ""
     Text2.SetFocus
     Exit Sub
  Else
     sql = "select * from user "
     rs_mima.Open sql, cn, adOpenKeyset, adLockPessimistic
     rs_mima.Fields(1) = Text2.Text
     rs_mima.Update
     MsgBox "密码修改成功"
     Unload Me
   End If
   

End Sub

Private Sub Command2_Click()
Unload Me

End Sub

Private Sub Form_Load()
Text1.Text = frmLogin.Text1.Text

End Sub


出错提示“from 子句语法错误”
提示错误在“rs_adduser.Open sql, cn, adOpenKeyset, adLockPessimistic”
2008-05-27 19:00
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
得分:0 
select * from [user] .....

user可能是sql保留字。

本来一直建议给表名加前缀的
2008-05-27 20:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-216190-1-1.html




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

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