title: How to assign mysql value to a single variable in vb.net?
body: <p>The following is my code for forgot password,
  I want to store the value of mysql query in a variable so that i can use the variable value for placing it in a email. </p>
  
  <pre><code>Private Sub Button3_Click(sender As Object, e As EventArgs) 
  Handles Button3.Click
  
          Dim p_text As String
          p_text = TextBox1.Text
          MsgBox(p_text)
          Dim i As Integer
          Try
  
              Dim conn As MySqlConnection
              conn = New MySqlConnection
              conn.ConnectionString ="server=192.168.1.111;userid=betterhomes;
              password=123456;database=betterhomes"
  
              conn.Open()
              Dim password As String = ""
              Dim sqlquery2 As String = "SELECT bh_password FROM bh_login 
              where job_id = '" &amp; p_text &amp; "';"
  
              Dim data2 As MySqlDataReader
              Dim adapter2 As New MySqlDataAdapter
              Dim command2 As New MySqlCommand
              command2.CommandText = sqlquery2
              command2.Connection = conn
              adapter2.SelectCommand = command2
              data2 = command2.ExecuteReader
  
              While data2.HasRows
                  password = data2.GetString("bh_password")
                  MsgBox(password)
                  data2.Close()
              End While
  
          Catch exError As MySqlException
              '  MsgBox("Error connecting to database! Try again later")
          End Try
  
      End Sub
  
  End Class
  </code></pre>