REAL PROBLEM: I am making a admin control panel for my mysql database. I just learned the most of the stuff in vb.net i know everything now learning query language and i run into this question. I want that there would be a user validator(detector) what i mean is lets say someone is creating an account and the username exist it would show a messagebox that the username already exist and cancel creating the account.
Here is my code:
Imports MySql.Data.MySqlClient
Public Class Deathlairregnu
Dim MySqlConn As MySqlConnection
Dim MySqlCmd As MySqlCommand
Private Sub ButtonNUS_Click(sender As Object, e As EventArgs) Handles ButtonNUS.Click
MySqlConn = New MySqlConnection
MySqlConn.ConnectionString =
"server=localhost;userid=root;password=CONSORED;database=syscore"
Dim MySqlRea As MySqlDataReader
Try
MySqlConn.Open()
Dim Query As String
Query = "insert into syscore.normaluser (nusername,nemail,npass,nphone,ncity) values ('" & TextBoxNUsern.Text & "','" & TextBoxNEmail.Text & "','" & TextBoxNPass.Text & "','" & TextBoxNPhone.Text & "','" & TextBoxNCity.Text & "')"
MySqlCmd = New MySqlCommand(Query, MySqlConn)
MySqlRea = MySqlCmd.ExecuteReader
MessageBox.Show("Registration has been completed")
MySqlConn.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
MySqlConn.Dispose()
End Try
End Sub
End Class
OPTIONAL: Ok. I have another question maybe you can solve at the same time. How could i add guid generator when the register submit button is pressed if you know what i mean? i have it in my website asp.net that i made myself. Would be very nice and helpful.
Big thanks for those who will try to help me. I will check this topic every 5 minutes.