title: unable to execute a query on a local DB in VS 2010
body: <p>I am working with a local DB created in Access which I added as a DataSource to my C# project.</p>
  
  <p>Here is one of the tables of this database, table called <code>Session</code>:</p>
  
  <pre><code>(PK)sessionID   roomID      sessionDate     sessionTimeStart sessionTimeEnd
  1ACMP2343       MB0302       05/08/2013          12:00 AM       14:00 PM
  2ACMP2343       MB2031       05/05/2013          09:00 AM       11:00 PM
  1ACMP3456       TRY223       15/05/2013          12:00 AM       13:00 PM
  2ACMP3456       CMP200       01/05/2013          10:00 AM       13:00 PM
  1ABIO3422       MB2031       05/08/2013          11:00 AM       13:00 PM
  2ABIO3422       CMP200       01/04/2013          14:00 AM       16:00 PM
  1ABIO2217       MB0302       12/05/2013          16:00 AM       18:00 PM
  2ABIO2217       MB2031       03/05/2013          12:00 AM       14:00 PM   
  </code></pre>
  
  <p>I have a form with <code>listbox</code> with the list of rooms used in DB, <code>dataGridView</code> and a <code>button</code>. I would like to write a query that will return today's sessions for the given <code>roomID</code>. The user selects value from the listbox, clicks the button, and the results should appear in the <code>dataGridView</code></p>
  
  <p>So if I would select room MB0302, the result should be:</p>
  
  <pre><code>1ACMP2343       MB0302       05/08/2013          12:00 AM       14:00 PM
  </code></pre>
  
  <p>(There is one more session with this room number on the list, but occurs on different date than today)</p>
  
  <p>I have tried:</p>
  
  <pre><code>using System;
  using System.Data;
  using System.Data.OleDb;
  using System.Windows.Forms;
  
  public partial class RoomSelect : Form
  {
      DataTable queryResult = new DataTable();
      public string RoomID;
  
      public RoomSelect()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          switch (listBox1.SelectedItem.ToString())
          {
              case "MB0302":
                  RoomID = listBox1.SelectedItem.ToString();
                  roomQuery();
                  break;
              case "MC1001":
                  RoomID = listBox1.SelectedItem.ToString();
                  roomQuery();
                  break;
              case "MC3203":
                  RoomID = listBox1.SelectedItem.ToString();
                  roomQuery();
                  break;
              case "MC3204":
                  RoomID = listBox1.SelectedItem.ToString();
                  roomQuery();
                  break;
          }
      }
  
      public void roomQuery()
      {
          string ConnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Kacper\\Desktop\\AutoReg\\AutoReg\\AutoReg.accdb;";
          OleDbConnection MyConn = new OleDbConnection(ConnStr);
          MyConn.Open();
  
          //SQL query that todays sessions for the given roomID
          string query = @"SELECT se.SessionID, se.RoomID, se.SessionDate, se.SessionTimeStart, se.SessionTimeEnd" +
             " FROM Session se " +
             " WHERE se.RoomID = @RoomID " +
             " AND se.SessionDate = Date() ";
          OleDbCommand command = new OleDbCommand(query, MyConn);
          command.Parameters.Add("RoomID", OleDbType.Char).Value = RoomID;
  
          OleDbDataAdapter adapter = new OleDbDataAdapter(command);
          adapter.Fill(queryResult);
          if (queryResult.Rows.Count == 0)
          {
              MessageBox.Show("No active sessions today for the given room number");
              MyConn.Close();
          }
          else
          {
              dataGridView1.DataSource = queryResult;
              MyConn.Close();
          }
      }
  }
  </code></pre>
  
  <p>But when I run it and click on the button, I recieve an error on the line <code>adapter.Fill(queryResult);</code></p>
  
  <blockquote>
    <p><em>An unhandled exception of type <code>System.Data.OleDb.OleDbException</code> occurred in <code>System.Data.dll</code></em></p>
    
    <p><em>Additional information: <code>IErrorInfo.GetDescription</code> failed with <code>E_FAIL</code>(0x80004005).</em></p>
  </blockquote>
  
  <p>I have tried to simplify the query, removing the parameter, but the result remains the same. </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I have simplified my query to look like this: <code>string query = "SELECT * FROM [Session] ";</code>. This still does not produce any results, but the previous error has been replaced by 15 sec. freeze.</p>