title: specified cast is not valid
body: <p>Here is a code that retrieve values from the database, but my problem is that it throws out an exception saying "InvalidCastException was unhandled specified cast is not valid". I am now confused what went wrong, The code and the table stated below.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>Public connstring As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source =" &amp; Application.StartupPath &amp; 
                  "\TestData.accdb; Persist Security info = false"
  Public Conn As New OleDbConnection
  
  Private Sub TestForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loard
      Conn.ConnectionString = connstring
      Conn.Open()
  
      LoadValue( )
  
  End Sub 
  
  Private Sub LoadValue( )
      Dim i As Integer    
      Dim cmd As OleDbCommand = New OleDbCommand
  
      With cmd
          .CommandText = "SELECT MAX(Guard_ID) FROM Guard"
          .CommandType = CommandType.Text
          .Connection = Conn
          .ExecuteNonQuery()
  
          Dim reader As OleDbDataReader = cmd.ExecuteReader
  
  
          If reader.Read Then
  
              TextBox1.Text = reader.GetString(0)
          i = TextBox1.Text + 1
          TextBox1.Text = i
  
              reader.Close()
          End If
      End With
  
  End Sub 
  </code></pre>
  
  <p>The table reference:</p>
  
  <p><img src="https://i.stack.imgur.com/Zl5TS.jpg" alt="enter image description here"></p>
  
  <p>Exception Error:</p>
  
  <p><img src="https://i.stack.imgur.com/4tQ9G.jpg" alt="enter image description here"></p>
  
  <p>I am really confused now on why the code does not work, any help and advice will be gladly accepted. Thanks in advance.</p>