title: vb.net Filling Textbox On combobox Selected Index Changed with sql database
body: <p>after i programming this code for fill text-box when combo-box selected Index changed </p>
  
  <p>i got this error 'Object reference not set to an instance of an object.',
   whats can i do ?? </p>
  
  <pre><code>Private Sub participant1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles participant1.SelectedIndexChanged
  
      Try
          Dim cmd As SqlCommand = New SqlCommand()
          Dim datareader As SqlDataReader = Nothing
          If Class1.sqlcon.State = ConnectionState.Open Then
              Class1.sqlcon.Close()
          End If
          Class1.sqlcon.Open()
          Dim query As String
          query = " select * from tparticipant where namea = '" &amp; participant1.Text &amp; "'"
          cmd = New SqlCommand(query, Class1.sqlcon)
          While datareader.Read
              If datareader IsNot Nothing Then
                  ID.Text = datareader.GetInt32("ID")
                  total.Text = datareader.GetInt32("total")
              End If
  
          End While
  
      Catch ex As Exception
          MessageBox.Show(ex.Message)
      End Try`
  </code></pre>