Lat
Lat

Reputation: 35

VB.NET set a password length to save in database

How to make the password entered by the user must be more than 8? This is my code but it didn't work

I tried to register with a password less than 8 and it was saved

If PasswordTextBox.Text >= 8 Then
                Try
                    Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\User\Documents\Database2.accdb")
                    Dim insert As String = "Insert into Table1 values('" & NameTextBox.Text & "','" & Staff_IDTextBox.Text & "','" & Phone_NoTextBox.Text & "','" & UsernameTextBox.Text & "','" & PasswordTextBox.Text & "');"
                    Dim cmd As New OleDbCommand(insert, conn)
                    conn.Open()
                    cmd.ExecuteNonQuery()
                    MsgBox("Saved")
                    Me.Close()
                Catch ex As Exception
                    MsgBox("Error")
                End Try
            Else
                MsgBox("Password must be more than 8 character")
            End If

Upvotes: 1

Views: 298

Answers (1)

Rowan Freeman
Rowan Freeman

Reputation: 16358

You should check the length. Something like

If PasswordTextBox.Text.Length >= 8 Then

Upvotes: 1

Related Questions