Home > Software engineering >  Using VB to write a login and authentication window, a run red place has been an error, don't k
Using VB to write a login and authentication window, a run red place has been an error, don't k

Time:09-27

'database there are two tables, one is to put the current data, and there's a account information table, used to check the account and password
Dim the db As New ADODB. Connection
Dim the rs As New ADODB. You
Dim strSQL As String

Private Sub Command1_Click ()
The ConnectionString="Provider=Microsoft. Jet. The OLEDB. 4.0; Data Source=C: \ Documents and Settings \ as long as the current state of the instance \ \ desktop \ VBA self-study system \ status management. MDB. Persist Security Info=False "
The Open
If Combo1. Text="Or" Text1="" Then
MsgBox "sorry, input account or password cannot be empty." , 16, "login failed!"
The Exit Sub
End the If

If Combo1. Text & lt;> "" And Text1 & lt;> "" Then
StrSQL="select * from login account information Where name='" & amp; Combo1. Text & amp; "' and password='" & amp; Text1. Text & amp; "'
"End the If
rs. Open strSQL, db, 3, 1
If the Trim (rs) Fields (" login name "))=Trim (Combo1. Text) And Trim (rs) Fields (" password "))=Trim (Text1. Text) Then
MsgBox "login successful!" , "congratulations!"
Addxk. Show
Unload Me
The Else
MsgBox "sorry, no this user, please enter again!" , 16, "login failed!"
Combo1. Text=""
Text1. Text=""
Combo1. SetFocus
End the If
Rs. Close
The Close
End Sub

CodePudding user response:

What is the error information?

CodePudding user response:

Hello, thank you for your answer, put the individual account information in a database can solve the problem, I don't know why two tables in a database
  • Related