| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2012 人关注过本帖
标题:[求助] 求一段vb用户登陆窗口代码,要求连接access数据库
只看楼主 加入收藏
wqq0712
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-5-1
收藏
 问题点数:0 回复次数:1 
[求助] 求一段vb用户登陆窗口代码,要求连接access数据库

求一段用户登陆(用户名 口令)的代码!
登陆用户记录是用ACCESS做的!access里的记录我已经搞好了~
有找到一段代码,可是是连接SQL的!
我要的是要连接到ACCESS的!
请大家帮忙搞下~把重要的那几句写给我!谢谢!


Private Sub Command1_Click()
Dim mrc As Adodb.Recordset
Dim txtsql As String
txtsql = "select * from oper where 用户名='" & Trim$(Text1(0).Text) & "'" & "and 口令='" & Trim$(Text(1).Text) + "'"
Set mrc = exesql(txtsql)
If mrc.RecordCount = 0 Then '未找到该用户记录
n = n + 1
If n < 3 Then
MsgBox "没有这个用户,继续登陆", vbOKOnly + vbExclamation, "信息提示"
Text1(0).Text = ""
Text1(1).Text = ""
Text1(0).SetFocus
Else
MsgBox "已经登陆失败三次,退出系统", 0 + 48, "提示信息"
mrc.Close '关闭记录集对象
Unload Me
End If
Else '找到合法用户
mrc.Close
Unload Me
frmmain.Show 1
End If
End Sub

搜索更多相关主题的帖子: 数据库 access 窗口 代码 用户 
2006-05-01 16:29
kankanba
Rank: 1
等 级:新手上路
帖 子:62
专家分:0
注 册:2005-10-24
收藏
得分:0 

Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Public OK As Boolean
Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim MsgText As String
Dim miCount As Integer


Private Sub Form_Load()

Dim i As Integer
i = 0
txtSQL = "select * from user"
Set mrc = ExecuteSQL(txtSQL, MsgText)
With txtUserName
Do While Not mrc.EOF
i = i + 1
.AddItem Trim(mrc!user_ID)
mrc.MoveNext
Loop
.ListIndex = i - 1
End With
mrc.Close
OK = False
miCount = 0
End Sub


Private Sub cmdOK_Click()

txtSQL = "select * from user where user_ID = '" & txtUserName.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If

End If
miCount = miCount + 1
If miCount = 3 Then
Me.Hide
End If
Exit Sub

End Sub

2006-05-01 16:48
快速回复:[求助] 求一段vb用户登陆窗口代码,要求连接access数据库
数据加载中...
 
   



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

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