access用户名密码 代码 求翻译 30

OptionCompareDatabasePrivateSubcmd确定_Click()EndSubPrivateSubcmd确定_enter()DimcnnAsNewA... Option Compare Database
Private Sub cmd确定_Click()
End Sub
Private Sub cmd确定_enter()
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
Dim name As String, passwd As String
Set cnn = CurrentProject.Connection
If IsNull(Me!txt用户名) Or Me!txt用户名 = "" Then
MsgBox "用户名不能为空!", vbCritical, "警告消息"
Me!txt用户名.SetFocus
ElseIf IsNull(Me!txt密码) Or Me!txt密码 = "" Then
MsgBox "请输入密码!", vbCritical, "警告消息"
Me!txt密码.SetFocus
Else
name = Me!txt用户名
passwd = Me!txt密码
strSQL = "SELECT * FROM 用户 WHERE 用户ID = '" & name & " 'and 用户密码 = '" & passwd & " ' "
rs.Open strSQL, cnn, adOpenKeyset
If rs.EOF Then
MsgBox " 您输入的用户名和密码有误,请重新输入!", vbCritical, "警告消息"
Me!txt用户名 = ""
Me!txt密码 = ""
Me!txt用户名.SetFocus
Else
MsgBox "欢迎进入教学管理系统!", vbCritical, "欢迎"
Me!txt用户名 = ""
Me!txt密码 = ""
End If
rs.Close
End If
cnn.Close

End Sub
Private Sub cmd退出_enter()

End Sub
Private Sub Form_Load()
End Sub
急用啊!!!!
展开
 我来答
chinaboyzyq
2015-01-04 · TA获得超过1.3万个赞
知道大有可为答主
回答量:1.3万
采纳率:89%
帮助的人:3288万
展开全部
Option Compare Database
Private Sub cmd确定_Click()
End Sub
Private Sub cmd确定_enter()
Dim cnn As New ADODB.Connection‘定义数据库连接
Dim rs As New ADODB.Recordset’定义记录集
Dim strSQL As String
Dim name As String, passwd As String
Set cnn = CurrentProject.Connection‘设置连接
If IsNull(Me!txt用户名) Or Me!txt用户名 = "" Then
MsgBox "用户名不能为空!", vbCritical, "警告消息"
Me!txt用户名.SetFocus
ElseIf IsNull(Me!txt密码) Or Me!txt密码 = "" Then
MsgBox "请输入密码!", vbCritical, "警告消息"
Me!txt密码.SetFocus
Else
name = Me!txt用户名
passwd = Me!txt密码
strSQL = "SELECT * FROM 用户 WHERE 用户ID = '" & name & " 'and 用户密码 = '" & passwd & " ' "
rs.Open strSQL, cnn, adOpenKeyset’查询用户名和密码是否存在
If rs.EOF Then‘如果不存在
MsgBox " 您输入的用户名和密码有误,请重新输入!", vbCritical, "警告消息"
Me!txt用户名 = ""
Me!txt密码 = ""
Me!txt用户名.SetFocus
Else’如果存在
MsgBox "欢迎进入教学管理系统!", vbCritical, "欢迎"
Me!txt用户名 = ""
Me!txt密码 = ""
End If
rs.Close‘关闭记录集
End If
cnn.Close’关闭连接

End Sub
Private Sub cmd退出_enter()

End Sub
Private Sub Form_Load()
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式