title: Login system with mysql detect the user id in VB.net
body: <p>I created a form that has a login system connected to a MySQL database, information making a table that has 3 columns: User ID, username and email</p>
  
  <p>Table representation:</p>
  
  <pre><code>    +---------+-------------+--------------------+
      | user_id |   username  |  email             |
      +---------+-------------+--------------------+
      |    1    |  test1      | email@domain.com   |
      |    2    |  test2      | user2@email.com    |
      +---------+-------------+--------------------+
  </code></pre>
  
  <p>When the form opens asks them to put a username and an email, I wondered if the application can verify that data set and detect the user ID, then put the user id in a textbox</p>
  
  <p>EXAMPLE: I log in with the account "test1 , Put your email "email@domain.com".</p>
  
  <p>I click on "Login" Then, consulting the user id account "test1" and put the user id in textbox "txtUserID".</p>
  
  <p>My progress so far (Login Button) I just need the consultation of user id:</p>
  
  <pre><code>Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
      MySqlConnection = New MySqlConnection
      MySqlConnection.ConnectionString = "server=Host;Port=3306; user id=Username;password=password; database=database_name"
      MySqlConnection.Open()
  
      Dim MyAdapter As New MySqlDataAdapter
      Dim sqlquery = "SELECT * FROM xf_user WHERE username='" &amp; txtUsername.Text &amp; "' AND email='" &amp; txtPassword.Text &amp; "';"
      Dim command As New MySqlCommand
      command.Connection = MySqlConnection
      command.CommandText = sqlquery
  
      MyAdapter.SelectCommand = command
      Dim Mydata As MySqlDataReader
      Mydata = command.ExecuteReader
  
      If Mydata.HasRows = 0 Then
          Form4.Show()
      Else
          Timer1.Start()
      End If
  End Sub
  </code></pre>
  
  <p>I hope it is possible , to note that not I have a lot of experience and can help me too if an expert.</p>
  
  <p>Thank you.</p>