title: Loading datagridview in VB.NET programmatically using dataset
body: <p>I've created a datagridview, <code>dataGridReport</code> in the Designer view of VB 2010.
  I'm then using a query to fill a dataset, and I want this dataset to populate the datagridview... but it doesn't seem to work.</p>
  
  <p>This is my code:</p>
  
  <pre><code>Dim con As New OleDb.OleDbConnection
  con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;
                           Data Source=C:\Users\Administrator\Documents\MenuDB.accdb"
  con.Open()
  Dim ds As DataSet = New DataSet
  Dim adapter As New OleDb.OleDbDataAdapter
  Dim sql As String
  
  sql = @"SELECT OrderDate, MenuItem 
          FROM   MenuItems, Orders 
          WHERE  Orders.itemID = MenuItems.ID 
             AND Format(Orders.OrderDate,'mm/dd/yyyy') &gt;= #" + fromDate + "# 
             AND Format(Orders.OrderDate,'mm/dd/yyyy') &lt;= #" + toDate + "#"
  
  adapter.SelectCommand = New OleDb.OleDbCommand(sql, con)
  adapter.Fill(ds)
  dataGridReport.DataSource = ds
  </code></pre>
  
  <p>I know something's missing now - I've looked around and most people seem to use something like <code>dataGridReport.DataSource = ds.Tables('somereference')</code></p>
  
  <p>But mine is a dynamically created dataset from a query joining two tables, it's not something stored among the project Data Sources. I also haven't bound the datagridview to any datasource via its properties. What am I missing? </p>
  
  <p>(By the way, the sql query is correct, I've tested it and returns expected results).</p>