title: Exception when trying to fill DataTable with SqlDataAdapter
body: <p>I am trying to make a SQL Login Form in VB.NET and it's not really working, well the form is loading but when i click Log in then it just crashes with an exception. Can someone tell me how to fix this?</p>
  
  <p>Code:</p>
  
  <pre><code>Imports System.Data.SqlClient
  
  Public Class Form1
  
  Private Sub BTN_LOGIN_Click(sender As Object, e As EventArgs) Handles     BTN_LOGIN.Click
  
      Dim connection As New SqlConnection("Server= (localdb)\MSSQLLocalDB; Database = TestDB; Integrated Security = true")
  
      Dim command As New SqlCommand("select * from Table where Username = @username and Password = @password", connection)
  
      Dim reg As New SqlCommand("INSERT INTO Table (username, password) VALUES (@username, @password)")
  
      command.Parameters.Add("@username", SqlDbType.VarChar).Value = TextBoxUsername.Text
      command.Parameters.Add("@password", SqlDbType.VarChar).Value = TextBoxPassword.Text
  
      Dim adapter As New SqlDataAdapter(command)
  
      Dim data As New DataTable()
  
      adapter.Fill(data)
  
      adapter.Dispose()
  
      If data.Rows.Count() &lt;= 0 Then
  
          MessageBox.Show("Username Or Password Are Invalid")
  
  
      Else
  
          MessageBox.Show("Login Successfully")
  
          Dim frm As New Form2()
  
          Me.Hide()
  
          frm.Show()
  
      End If
  
  End Sub
  
  Private Sub BTN_CANCEL_Click(sender As Object, e As EventArgs) Handles BTN_CANCEL.Click
  
      Me.Close()
  
  End Sub
  End Class
  </code></pre>
  
  <p>Also the table is fine. Just don't talk about the table</p>
  
  <p><img src="https://i.stack.imgur.com/87gmG.png" alt="Exception"></p>