ACCESS登陆的问题!今天送分!

yiyongxiang 2003-04-06 04:16:58
要求是:
调用ACCESS中的信息,正确的用户和密码才能登陆,对不同的用户密码是不相同的。而登陆的数据在ACCESS中,谢谢。
...全文
24 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
wxy001 2003-04-06
我来说两句

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Public OK As Boolean
Private Sub Form_Load()
Dim sBuffer As String
Dim lSize As Long
Me.Data1.DatabaseName = App.Path & "\数据库名.MDB"
Me.Data1.RecordSource = " SELECT * FROM 表名"
Me.Data1.Refresh
If Data1.Recordset.RecordCount = 0 Then
Data1.Recordset.AddNew
Data1.Recordset.Update
End If
Data1.Recordset.MoveFirst
If Data1.Recordset("**") = False Then
frm表.Show 1
Me.Data1.Refresh
Me.Data1.Recordset.MoveFirst
End If
Data1.Refresh

wxyname = Data1.Recordset("姓名")
wxypassword = Data1.Recordset("密码")
txtUserName.Text = wxyname
End Sub
Private Sub cmdCancel_Click()
OK = False
Me.Hide
End Sub


Private Sub cmdOK_Click()
'ToDo: 创建测试密码是否正确
'检查正确密码
If Trim(txtPassword.Text) = Trim(wxypassword) Then
OK = True
Me.Hide
frmMain.Show
Else
MsgBox "密码错误,再试一次!", , "登录"
txtPassword.SetFocus
txtPassword.SelStart = 0
txtPassword.SelLength = Len(txtPassword.Text)
End If
End Sub
同时再掉用点东西!
回复
heipifeng 2003-04-06
都说完了。不会也会了。呵呵
回复
chenyu5188 2003-04-06
创建一个用户表,字段用户名和密码
回复
qiqif 2003-04-06
设一张密码表
有用户名和密码
回复
pcwak 2003-04-06
多用户登录
Private Sub cmdOk_Click()
Dim strUserPass As String
'判断用户是否已经输入用户名和密码
golUsername = Trim(txtName.Text)
strUserPass = Trim(txtPass.Text)
If golUsername = "" Then
MsgBox "请输入用户名", vbExclamation, "登录提示"
txtName.SetFocus
Exit Sub
End If
If strUserPass = "" Then
MsgBox "请输入密码", vbExclamation, "登录提示"
txtPass.SetFocus
Exit Sub
End If
'判断用户登录信息是否正确
sRs.Open "select * from TAB_User where 用户名='" & golUsername & "'", sCon, adOpenStatic, adLockOptimistic
If sRs.EOF Then
MsgBox "没有此用户", vbCritical, "登录错误"
txtName.SelStart = 0
txtName.SelLength = Len(txtName.Text)
txtName.SetFocus
sRs.Close
Exit Sub
End If
sRs.Close
sRs.Open "select * from TAB_User where 用户名='" & golUsername & "' and 用户密码='" & strUserPass & "'", sCon, adOpenStatic, adLockOptimistic
If sRs.EOF Then
MsgBox "密码错误", vbCritical, "登录错误"
txtPass.SelStart = 0
txtPass.SelLength = Len(txtPass.Text)
txtPass.SetFocus
sRs.Close
Exit Sub
End If
sRs.Close
ExecuteCommand "update TAB_user set 最近登录时间=#" & Now & "# where 用户名='" & golUsername & "'"
MDIFormMain.Show
Unload Me
End Sub
回复
sxs69 2003-04-06
Option Explicit
Dim User As String 'UserNo存放用户编号
Dim Pass As String 'Password存放用户密码

Private Sub Form_Load()
Data1.DatabaseName = App.Path & "\PASS.MDB"
Data1.RecordSource = "PASS"
End Sub
Private Sub cmdOK_Click()
User = Text1.Text
Pass = Text2.Text
Data1.Recordset.FindFirst " UserNo = '" & User & "'"
If Data1.Recordset.NoMatch Then
MsgBox "用户名输入错误!"
Exit Sub
Else
If Data1.Recordset!Password <> Pass Then
MsgBox "密码输入错误!"
Exit Sub
End If
End If
End Sub
回复
流梓 2003-04-06
可以在输入用户和密码时判断一下不就可以了吗。

比如:

先用SQL语句:select * from 表

if rs!用户名=text1 then
给它的权限是什么
end if

还有可以在数据库用户名表中,填加一些字段用来却认权限,再在VB中判断即可。
回复
zhenxizhou 2003-04-06
看看这个源码:
http://www.csdn.net/cnshare/soft/14/14847.shtm
下载第三方控件的网址:
http://www.pdriver.com/activex/f1setup.exe
回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2003-04-06 04:16
社区公告
暂无公告