I wanted to create a form where a user can create an account, have it loaded in SQL, and be able to retrieve the information and validate it. I've reached a mental block on the validation code and need some advice. Here is my code so far:
Public Class main
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblUsername.Click
End Sub
Private Sub btnJoin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnJoin.Click
lblName.Visible = True
lblUsername.Visible = True
lblPassword.Visible = True
txtName.Visible = True
txtUsername.Visible = True
txtPassword.Visible = True
btnNext.Visible = True
End Sub
Private Sub main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
SqlConnection1.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
DBAuser.InsertCommand.CommandText = "INSERT INTO login (userName, login, password) VALUES ('" + txtName.Text.Replace("'", "") + "', '" + txtUsername.Text.Replace("'", "") + "', '" + txtPassword.Text.Replace("'", "") + "');"
DBAuser.InsertCommand.ExecuteNonQuery()
MessageBox.Show("Account Created Successfully")
txtName.Clear()
txtUsername.Clear()
txtPassword.Clear()
lblName.Visible = False
lblUsername.Visible = False
lblPassword.Visible = False
txtName.Visible = False
txtUsername.Visible = False
txtPassword.Visible = False
btnNext.Visible = False
End Sub
Private Sub btnUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUser.Click
'got stuck here :(
DBAuser.SelectCommand.CommandText = "SELECT login,password FROM login WHERE userName = '" & txtUsername2.Text & "' AND password = '" & txtPassword2.Text & "'"
End Sub
End Class
Do i need some sort of Epic if statement to validate what the user inputted into the text boxes or am i on the wrong path?
Thanks