title: How to get data from database to textbox on VB.net
body: <p>hi im new in Visual basic. I have a button that when its clicked, its gonna find the student via their ID inputted by the user and its gonna output the data to the textfields. I'm not pretty sure if im doing this right. because i'm getting this error [image] >> <a href="http://img812.imageshack.us/img812/7650/gq0z.png" rel="nofollow">http://img812.imageshack.us/img812/7650/gq0z.png</a> </p>
  
  <p>btw here's my code so far. can someone help me please? thanks!</p>
  
  <pre><code>        cmd.CommandText = "Select * from Student where Student_id = '" &amp; id.Text &amp; "'"
          cmd.Connection = db
  
          dr = cmd.ExecuteReader
  
          Try
              dr.Read()
              id.Text = dr.GetValue(0)
              Lname.Text = dr.GetValue(1)
              Fname.Text = dr.GetValue(2)
              Mname.Text = dr.GetValue(3)
              datet.Text = dr.GetValue(4)
              age.Text = dr.GetValue(5)
              male.Text = dr.GetValue(6)
              female.Text = dr.GetValue(7)
              status.Text = dr.GetValue(8)
              staddress.Text = dr.GetValue(9)
              cityAdd.Text = dr.GetValue(10)
              dr.Close()
  
          Catch ex As Exception
              MsgBox("" + ex.Message)
              dr.Close()
          End Try
  </code></pre>