title: The selection sql statement is not responding to date value
body: <p>I am trying to select items from a database where their date equals the date in the Session. It says there is no row at position <code>[0][2]</code>, but there is actually a row there. This is my code:</p>
  
  <pre><code>DateTime b = Convert.ToDateTime(Session["Dat"]);
  int D = b.Day;
  int M = b.Month;
  int Y = b.Year;
  string dat = M + "/" + D + "/" + Y ;
  
  DataTable m;
  m = DAL.SelectFromTable(
     "SELECT * FROM [ToDoList] where [UserID]='" + k + "' and  [D]="+ dat);
  if (m.Rows.Count &gt; 0)
  {
      Response.Write("&lt;/br&gt;&lt;/br&gt;&lt;/br&gt;&lt;center&gt;" + m.Rows[0][2].ToString() + "&lt;/center&gt;");
  }
  </code></pre>