-4

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.

Adam Lear
  • 38,111
  • 12
  • 81
  • 101

2 Answers2

0

Adding a uniqueidentifier column and adding the default to generate new guid

Downvotes probably because you didn't paste your code here, plus the fact that the question has been asked and answered many times. Did you search before asking?

Community
  • 1
  • 1
CottonHill
  • 73
  • 6
0

I did the important part. Optional is not needed for me but would've been good. Here: https://www.youtube.com/watch?v=ovoVfHW3Q8Y.

Adam Lear
  • 38,111
  • 12
  • 81
  • 101