Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub btnRegister_Click(sender As Object, e As EventArgs) Handles btnRegister.Click
- Conn = New MySqlConnection
- Conn.ConnectionString = "server=localhost;userid=root;password=mmmsss123;database=gymdb"
- txtUName.Text = txtUName.Text.ToLower()
- txtUName.Text = txtUName.Text.Replace(" ", "")
- txtPassword.Text = txtPassword.Text.ToLower()
- txtPassword.Text = txtPassword.Text.Replace(" ", "")
- Try
- Conn.Open()
- Dim Query As String
- Query = "select * from gymdb.user where username='" & txtUName.Text & "'"
- Cmd = New MySqlCommand(Query, Conn)
- Cmd.ExecuteNonQuery()
- Rdr = Cmd.ExecuteReader
- Dim Count As Integer = 0
- While Rdr.Read
- Count += 1
- End While
- Rdr.Close()
- Conn.Close()
- If Count >= 1 Then
- MessageBox.Show("This Username Is Already Registered!" & Environment.NewLine & "Please Enter Another Username", "Registeration State")
- Else
- If txtUName.Text <> "" And txtPassword.Text <> "" Then
- Conn.Open()
- Query = "insert into gymdb.user (username, upassword) values ('" & txtUName.Text & "', '" & txtPassword.Text & "')"
- Cmd1 = New MySqlCommand(Query, Conn)
- MessageBox.Show("Registered Successfully!", "Registeration State")
- Conn.Close()
- Else
- MessageBox.Show("Not Valid Username Or Password!" & Environment.NewLine & "Please Enter Valid Username And Password", "Registeration State")
- End If
- End If
- Catch ex As MySqlException
- MessageBox.Show(ex.Message, "Error!")
- Finally
- Conn.Dispose()
- End Try
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement