title: Get RadioButton value for gender from a MS Access database
body: <p>How can I retrieve the gender value from my MS Access database?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
      myconnection = New OleDbConnection(StrConn)
      myconnection.Open()
      Dim str As String
      str = "SELECT * FROM register WHERE (MatricNum = '" &amp; txtSearch.Text &amp; "')"
      Dim cmd As OleDbCommand = New OleDbCommand(str, myconnection)
      dr = cmd.ExecuteReader
      While dr.Read()
          txtMatricnum.Text = dr("MatricNum").ToString
          txtFname.Text = dr("Fname").ToString
          txtLname.Text = dr("Lname").ToString
          rbtMale .Text or rbtfemale.Text  = dr("Gender").ToString
          DateTimePicker1.Value = dr("DOB").ToString
          txtlevel.Text = dr("Level").ToString
          txtFaculty.Text = dr("Faculty").ToString
          txtDapartment.Text = dr("Department").ToString
          txtContact.Text = dr("Contact").ToString
          txtState.Text = dr("State").ToString
          txtLGA.Text = dr("LGA").ToString
          txtAddress.Text = dr("Address").ToString
          Try
              Dim data As Byte() = DirectCast(dr("Picture"), Byte())
              Dim ms As New IO.MemoryStream(data)
              PictureBox1.Image = Image.FromStream(ms)
          Catch ex As Exception
              MsgBox(ex.Message)
          End Try
      End While
      myconnection.Close()
  End Sub
  </code></pre>