@@ -9,34 +9,36 @@ Public Class Login
9
9
Dim username As String = UsernameTextBox.Text
10
10
Dim password As String = PasswordTextBox.Text
11
11
12
- ' Check if password or username is empty give error
12
+ 'Check if password or username is empty give error
13
13
If String .IsNullOrEmpty(username) Or String .IsNullOrEmpty(password) Then
14
14
MessageBox.Show( "Username or email can not be empty." )
15
- Else
16
- ' Creates a query to select user.
17
- Dim query As String = "SELECT * FROM users_table WHERE username = '" + username + "' AND password = '" + password + "'"
15
+ Return
16
+ End If
18
17
19
- Dim cmd As New SqlDataAdapter(query, con)
20
- Dim dt As New DataTable()
18
+ 'Creates a query to select user.
19
+ Dim query As String = "SELECT * FROM users_table WHERE username = '" + username + "' AND password = '" + password + "'"
21
20
22
- ' Fill the data table with results from database
23
- cmd.Fill(dt )
21
+ Dim cmd As New SqlDataAdapter(query, con)
22
+ Dim dt As New DataTable( )
24
23
25
- ' Check if user exist with given username and password
26
- If dt.Rows.Count > 0 Then
27
- ' Hide the login form
28
- Me .Hide()
24
+ 'Fill the data table with results from database
25
+ cmd.Fill(dt)
29
26
30
- ' Reset the username and password input.
31
- UsernameTextBox.Text = ""
32
- PasswordTextBox.Text = ""
27
+ 'Check if user exist with given username and password
28
+ If dt.Rows.Count = 0 Then
29
+ MessageBox.Show( "Incorrect Username or password." )
30
+ Return
31
+ End If
33
32
34
- ' Show the dashboard form
35
- Dashboard.Show()
36
- Else
37
- MessageBox.Show( "Username or password is incorrect" )
38
- End If
33
+ 'Hide the login form
34
+ Me .Hide()
35
+
36
+ 'Reset the username and password input.
37
+ UsernameTextBox.Text = ""
38
+ PasswordTextBox.Text = ""
39
+
40
+ 'Show the dashboard form
41
+ Dashboard.Show()
39
42
40
- End If
41
43
End Sub
42
44
End Class
0 commit comments