发布网友 发布时间:2024-10-24 18:58
共2个回答
热心网友 时间:9小时前
Private Sub cmdCancle_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim sql As String
Dim rs_login As New ADODB.Recordset
Dim conn As New ADODB.Connection
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database.mdb"
If Trim(text1.Text) = "" Then
MsgBox "用户名不能为空,请重新输入!"
text1.SetFocus
Else
sql = "select * from 用户表 where user_ID='" & Trim(text1.Text) & "'"
rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic
If rs_login.EOF = True Then
MsgBox "没有这个用户,请重输入!", vbOKOnly + vbExclamation, ""
text1.Text = ""
text1.SetFocus
Else
username = text1.Text
If Trim(rs_login.Fields(1)) = Trim(text2.Text) Then
Unload Me
图书馆理系统.Show
Else
MsgBox "密码不正确,请重输入!", vbOKOnly + vbExclamation, ""
text2.SetFocus
text2.Text = ""
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
End Sub
Private Sub Form_Load()
cnt = 0
End Sub
这是vb+sql的用户登陆代码
热心网友 时间:9小时前
数据库换了~
当然要改的代码也不少