title: VB: Fill multiple textboxes with data from MySQL DB
body: <p>So, I have this program which has to store a lot of different info from users and shows it through Textboxes, Numerics, etc when the Form loads. At first I thought it would be easy, but as soon as I started writing the code I figured that if I would do the easy way (the way I know) I would have to write hundreds of Subs, each one with a MySQL query and then assign, one by one, the values to their respective textboxes, comboboxes, etc.</p>
  
  <p>So, how can I pull data from multiple rows from a MySQL DB and then assign the data from each one of those rows to textboxes?</p>
  
  <p>This is what I have now, which works fine, but only for getting one single value from the DB:</p>
  
  <pre><code>Imports MySql.Data.MySqlClient
  
  Public Class GetInfo
  
  
      Public Shared Sub Run()
  
          Dim reader As MySqlDataReader
          Dim result As String
  
          Dim Query_Read As String = "Select Nome FROM dk_db_sql_yog." &amp; Username
          Dim Cmd_Read_Name As New MySqlCommand(Query_Read)
          Cmd_Read_Name.Connection = Connect
          reader = Cmd_Read_Name.ExecuteReader()
          If reader.Read() Then
              If reader.IsDBNull(0) Then
                  result = ""
              Else
                  result = reader.GetString(0)
              End If
          End If
  
          Form1.Name_Textbox.Text = result
          reader.Close()
  
       End Sub
  
  End Class
  </code></pre>