| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1918 人关注过本帖, 1 人收藏
标题:vb+access(含表1,内有user password字段)怎样实现用户登陆,用adodc?
只看楼主 加入收藏
ptulove
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-4-24
收藏(1)
 问题点数:0 回复次数:7 
vb+access(含表1,内有user password字段)怎样实现用户登陆,用adodc?
用adodc
搜索更多相关主题的帖子: password 字段 adodc user access 
2008-04-24 21:17
sznt
Rank: 2
等 级:论坛游民
帖 子:161
专家分:20
注 册:2005-8-4
收藏
得分:0 
Private Sub cmdOK_Click()
On Error GoTo errh:
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    Set rs = cn.Execute("SELECT UserName , Password  FROM 超级用户 ")
    If rs.EOF Then
        rs.Close
        Set rs = Nothing
        Unload Me
        Load FrmMain
        Exit Sub
    End If
    rs.MoveFirst
    Dim i As Integer
    '校验是否为超级用户
    Do
        If rs.Fields("UserName") = txtUserName.Text Then
            If rs.Fields("Password") = txtPassword.Text Then
                UserType = True
                LoginSucceeded = True
                rs.Close
                If txtPassword.Text = "Admin" Then IsAdmin = True
                Unload Me
                Load FrmMain
                Exit Sub
                Exit Do
            End If
        End If
        rs.MoveNext
    Loop Until rs.EOF
    '校验是否为普通用户
    Set rs = cn.Execute("SELECT 学号 FROM 学生 WHERE 学号 =" & "'" & txtPassword.Text & "'")
    If rs.EOF Then
        MsgBox "无效密码或用户名请重试!", , "Login"
        txtPassword.SetFocus
        SendKeys "{Home}+{End}"
    Else
        rs.Close
        UserType = False
        LoginSucceeded = True
        Unload Me
        Load FrmMain
    End If
    Exit Sub
errh:
    MsgBox Err.Description
End Sub
2008-04-25 09:29
zougonghua
Rank: 1
等 级:新手上路
帖 子:163
专家分:0
注 册:2008-4-1
收藏
得分:0 
这里面cn.execute是什么,怎么没有定义
2008-04-25 14:58
sznt
Rank: 2
等 级:论坛游民
帖 子:161
专家分:20
注 册:2005-8-4
收藏
得分:0 
Option Explicit
Public UserType As Boolean '如果是true那么是超级用户
Public cn As ADODB.Connection '公共连接对象
Public searchSQL As String
Public IsAdmin As Boolean '判断是否为系统管理员登陆

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
2008-04-25 17:04
zougonghua
Rank: 1
等 级:新手上路
帖 子:163
专家分:0
注 册:2008-4-1
收藏
得分:0 
又是API函数,看不懂啊...
2008-04-26 08:00
luojia86
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2008-4-6
收藏
得分:0 
楼主相当有才!!!
2008-05-01 09:59
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
API不用看懂,会用就可以了......
API不就是函数吗?你看他的参数和返回值就可以了,不过在这个程序中,没看出来API的作用。

2008-05-01 11:03
jxyga111
Rank: 8Rank: 8
来 自:中華人民共和國
等 级:贵宾
威 望:33
帖 子:6015
专家分:895
注 册:2008-3-21
收藏
得分:0 
有必要用外部函數不?????
Dim strUserid, password As String
Dim objrs As New Recordset
Public objcn As New Connection
Private Sub Form_Load()
 objcn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=登入名;Initial Catalog=數據庫名;Data Source=計算機名"
    objrs.Open "t_login", objcn, adOpenKeyset, adLockOptimistic
End Sub

Private Sub connamd_Click()
    Form5.Show
    Unload Me
End Sub

Private Sub command_Click()
     strUserid = Text1.Text
    objrs.Requery
    objrs.Find ("id = '" & strUserid & "'")
    If objrs.EOF = False Then
        If IIf(IsNull(objrs.Fields("password")), "", objrs.Fields("password")) = Text2.Text Then
            strid = IIf(IsNull(objrs.Fields("id")), "", objrs.Fields("id"))
            strname = IIf(IsNull(objrs.Fields("name")), "", objrs.Fields("name"))
            Form1.Show
            Unload Me
        Else
            MsgBox "密碼不正確"
            Text2.Text = ""
            Text2.SetFocus
            Exit Sub
        End If
    Else
        MsgBox "帳號不正確"
        Text1.Text = ""
        Text1.SetFocus
        Exit Sub
    End If
End Sub

Private Sub command_Click()
    Unload Me
End Sub
2008-05-03 10:02
快速回复:vb+access(含表1,内有user password字段)怎样实现用户登陆,用adod ...
数据加载中...
 
   



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

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