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
急用啊!!!! 展开
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
急用啊!!!! 展开
1个回答
展开全部
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询