title: VB - Value cannot be null error
body: <p>The problem I am having is as follows:</p>
  
  <p>I am using an SQL query to take data out of a table like so:</p>
  
  <pre><code>Dim query As String = "SELECT Pronunciation, Character FROM [Hiragana List] WHERE Pronunciation='" &amp; pronunciation &amp; "';"
      Dim instruction = New SqlCommand(query, sqlCon)
      Dim da As New SqlDataAdapter
      da.SelectCommand = instruction
      da.Fill(HiraganaList)
  </code></pre>
  
  <p>This should then take the data from the table and fill-in a datatable called "Hiragana List", however when the code reaches the line</p>
  
  <pre><code>da.Fill(Hiragana List)
  </code></pre>
  
  <p>The operation of the program stops and it instead returns this error:</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.ArgumentNullException' occurred in System.Data.dll</p>
    
    <p>Additional information: Value cannot be null.</p>
  </blockquote>
  
  <p>I took a look at the "Hiragana List" table itself and changed it so that it would accept Nulls in each of the field in order to see if it would fix it, unfortunately it still returns the same error.  </p>
  
  <p>(edit) Here is the declaration for the datatable 'Hiragana List':</p>
  
  <pre><code>Dim connectionString As String = "Server=my_server;Database=name_of_db;User Id=user_name;Password=my_password"
  Dim sqlCon = New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename='J:\Computing Coursework\real project\KES\KES\Kana List.mdf';Integrated Security=True;Connect Timeout=30")
  Dim HiraganaList As DataTable
  Dim KanjiList As DataTable
  Dim Katakana As DataTable
  Dim YoonList As DataTable
  Dim YoonKataList As DataTable
  </code></pre>