title: VB.Net MySQL How to insert values to the database
body: <p>Pro Devs I'm using VB.Net with MySQL Database and I want to insert values in my DB. Example: I have values in my DB which are <strong>Admin11</strong> but when I insert another value <strong>admin11</strong> I get an error here's my code. by the way, these two methods are in different classes.</p>
  
  <p>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''</p>
  
  <p>here's my code to check if Username exists in the database...</p>
  
  <p>Public Sub checkUsernameIfExist()</p>
  
  <pre><code>    Dim con = New MySqlConnection
      con.ConnectionString = "server=localhost;userid=root;password=alpine;port=3305;database=pos_db;pooling=false;SslMode=none"
  
      con.Open()
      Dim query As String = "SELECT Username FROM pos_db.tblusers WHERE BINARY Username=@Users"
      Dim cmd As New MySqlCommand(query, con)
      cmd.Parameters.AddWithValue("@Users", frmLogin.txtUser.Text)
  
      Dim count As Integer = Convert.ToInt32(cmd.ExecuteScalar())
  
      If count &lt;&gt; 0 Then
          MessageBox.Show("Username is already taken. Please create a unique one!", "System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
          Return
      Else
          insertDataToTblUser.insertToLogin()
      End If
      con.Close()
      con.Dispose()
  End Sub
  </code></pre>
  
  <p>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''</p>
  
  <p>Here's my code in insert values......</p>
  
  <p>Dim con As MySqlConnection</p>
  
  <pre><code>Public Sub insertToLogin()
      con = New MySqlConnection
      con.ConnectionString = "server=localhost;userid=root;password=alpine;port=3305;database=pos_db;pooling=false;SslMode=none"
  
      con.Open()
  
      Dim qry As String = "INSERT INTO tblUsers (Username,Password,Level) VALUES (@User,@Pass,@lvl)"
      Dim cmd As New MySqlCommand(qry, con)
      cmd.Parameters.AddWithValue("@User", frmLogin.txtUser.Text)
      cmd.Parameters.AddWithValue("@Pass", frmLogin.txtPass.Text)
      cmd.Parameters.AddWithValue("@lvl", frmLogin.cmbUserlevel.Text)
      cmd.ExecuteNonQuery()
  
      MessageBox.Show("Sign Up Successful", "System", MessageBoxButtons.OK, MessageBoxIcon.Information)
  
      con.Close()
      con.Dispose()
  End Sub
  </code></pre>
  
  <p>Please help me thanks a lot.</p>