界面登录问题
Option ExplicitPrivate Sub denglujiemian_Click()
Dim username As String
Dim userpassword As String
Dim try_times As Integer
try_times = 0
username = Trim$(user.Text)
userpassword = Trim$(password.Text)
If user.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
user.SetFocus
Exit Sub
End If
If password.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
password.SetFocus
Exit Sub
End If
Dim strSQL As String
strSQL = "select * from staff where sno='" & username & "' and password='" & userpassword & "'"
Dim str As New ADODB.Recordset
Set str = New ADODB.Recordset
str.CursorLocation = adUseClient
str.Open strSQL, conn, adOpenStatic, adLockReadOnly
With str
If .State = adStateOpen Then .Close
.Open strSQL
If .EOF Then
try_times = try_times + 1
If try_times = 3 Then
MsgBox "您已经三次尝试进入本系统,均不成功,系统将会自动关闭", vbOKOnly + vbCritical, "警告"
Unload Me
Else
MsgBox "对不起,用户名不存在或密码不正确!", vbOKOnly + vbQuestion, "警告"
user.SetFocus
user.Text = ""
password.Text = ""
End If
Else
Unload Me
frm_main.Show
End If
End With
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Set conn = New ADODB.Recordset
conn.ConnectionString = "dsn=LMS"
conn.Open
Login.Show
End Sub
Private Sub password_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1.SetFocus
End If
End Sub
红色的地方运行的时候说没有定义 是怎么回事啊 --------------------编程问答-------------------- 1,代码中引用ADO
2,password是系统保留字在SQL语句中使用时需要改为[password]
strSQL = "select * from staff where sno='" & username & "' and [password]='" & userpassword & "'"
--------------------编程问答-------------------- 除
补充:VB , 数据库(包含打印,安装,报表)