I built a dialog so that when the user decides to print the DataGridView, he can select the date range for which to print. This works fine; however, either I am missing something or the filtering is not working properly. In order to filter by a range and for it to include the correct days, you have to select one day prior to the actual date you want to filter. It is like the filter is not inclusive. The dates are returned from two DateTimePickers and passed as a string to my function. The following is my code:
private void CreateFilteredDataGridView(DataGridView dgv, string fromDate, string toDate)
{
try
{
myDataSet = new DataSet();
myDataSet.CaseSensitive = true;
DataAdapter.SelectCommand.Connection = myConnection;
DataAdapter.TableMappings.Clear();
DataAdapter.TableMappings.Add("Table", "INVENTORY");
DataAdapter.Fill(myDataSet);
myDataView = new DataView(myDataSet.Tables["INVENTORY"], "TIMESTAMP >= '" + Convert.ToDateTime(fromDate) + "' AND TIMESTAMP <= '" + Convert.ToDateTime(toDate) + "'", "TIMESTAMP", DataViewRowState.CurrentRows);
dgv.DataSource = myDataView;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}