title: Unable to cast object of type DataTable to type System.IConvertible
body: <p>I've inherited an application which I'm struggling to troubleshoot. I'm not sure if this is the best way to have written the application and I would have done it differently, but I don't want to have to re-write it.</p>
  
  <p>The application has Oracle 10g as it's background db. It appears that my predecessor is sending two date parameters and formating them as System.Datetime (YYYY/MM/DD HH24:mm:ss). I think this might be the problem, but I'm not 100% certain. I've checked the NLS_DATE_FORMAT of the db and it's DD/MON/RR HH24:MI:SS and I'm thinking the error might because the wrong date format is being used to query the db. I would appreciate some help in solving this if possible.</p>
  
  <pre><code>int totalcount = System.Convert.ToInt32(adapter.GetValues(myStartDate, myStartDate.AddHours(1)));
  </code></pre>
  
  <p>//Code in Designer.cs - stepping through it by disabling 'Just my code'</p>
  
  <pre><code>public virtual Mytable.MytableDataTable GetValues(System.DateTime startDate, System.DateTime endDate) {
      this.Adapter.SelectCommand = this.CommandCollection[2];
      this.Adapter.SelectCommand.Parameters[0].Value = ((System.DateTime)(startDate));
      this.Adapter.SelectCommand.Parameters[1].Value = ((System.DateTime)(endDate));
      Mytable.MytableDataTable tdataTable = new Mytable.MytableDataTable(); *&lt;&lt;--- when I use the visualizer to view tdataTable, there's nothing in the table. This then throws the above titled error message.*
  
      this.Adapter.Fill(dataTable);
      return dataTable;
  
  }
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p>Created and ran a test and the test failed with the following message:
  'System.NullReferenceException: Object reference not set to an instance of an object.'</p>
  
  <p>Error in the stack trace:</p>
  
  <pre><code>        public void BookClub_BeforePrintTest()
      {
          BookClub_Accessor target = new BookClub_Accessor(); // TODO: Initialize to an appropriate value
          object sender = null; // TODO: Initialize to an appropriate value
          PrintEventArgs e = null; // TODO: Initialize to an appropriate value
          target.BookClub_BeforePrint(sender, e);
          Assert.Inconclusive("A method that does not return a value cannot be verified.");
      }
  </code></pre>