title: InvalidCastException when retrieving data from SqlDataReader
body: <p>How can I get rid of:<br></p>
  
  <blockquote>
    <p>System.InvalidCastException: 'Conversion from string "Type" to type
    'Integer' is not valid.'"<br></p>
  </blockquote>
  
  <p>On the line:<br></p>
  
  <pre class="lang-vb prettyprint-override"><code>Dim usertype = Reader.GetString("Type")
  </code></pre>
  
  <p>This is my full code:<br></p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Sub OKbt1_Click(sender As Object, e As EventArgs) Handles OKbt1.Click
      Call Connect() ' [ connection to module ]'
      Dim Reader As SqlDataReader
  
      Try
          Dim command As New SqlCommand("select * from uinfo where password = '" &amp; PASStb2.Text &amp; "'", sqlConn)
          Reader = command.ExecuteReader
          Reader.Read()
  
          Dim count As Integer = 0
  
          While Reader.Read
              count = count + 1
          End While
  
          If count = 1 Then
  
              ' ** MY ERROR **
              Dim usertype = Reader.GetString("Type")
  
              If usertype = "admin" Then
                  'MsgBox("username and password are correct")
                  MAIN_MENU.Show()
  
                  For a = 0 To 500
  
                  Next
                  Me.Hide()
                  sqlConn.Close()
                  sqlConn.Dispose()
  
              ElseIf usertype = "user" Then
  
                  For a = 0 To 500
  
                  Next
                  Me.Hide()
                  'MsgBox("username and password are correct")
                  USERMENU.Show()
  
              End If
  
          ElseIf count &gt; 1 Then
              MsgBox("username and password are duplicate")
  
          Else
              MsgBox("username and password are not correct")
          End If
  
          sqlConn.Close()
  
      Catch ex As SqlException
          MsgBox(ex.Message)
  
      Finally
          sqlConn.Dispose()
  
      End Try
  End Sub
  </code></pre>