Read starting and ending date of an event in the database

0

I made a report screen to read some values from a database. When I type for example 01/05/2017 (start date) and 05/31/2017 (end date) the bank returns me as I wanted. But when I type the end date for example (06/01/2017) the bank returns me null. What should I do?

DateTime DT_IN_General = new DateTime();
DateTime DT_OUT_General = new DateTime();

DT_IN_General = Convert.ToDateTime(DateIn.Text);
DT_OUT_General = Convert.ToDateTime(DateOut.Text);

if ((string) LB_Name_Equip.Content != "Selecionar Equipamento") {

 if (DateIn.Text != null) {
  if (DateOut.Text != null) {
   if (DT_IN_General < DT_OUT_General) {
    if ((string) LB_Name_Equip.Content == "EL 02") {
     DataGrid_ItemSource_Alarms_And_Events(Class.DataBaseSqlServerEquip.GetReportEvent_Table_EquipAlarmEvent(Convert.ToDateTime(DateIn.Value), Convert.ToDateTime(DateOut.Value), "_EL 02"));
    }

    public static DataTable GetReportEvent_Table_EquipAlarmEvent(DateTime DTIn, DateTime DTOut) {

      DataTable Data = new DataTable();


      try {
       string CommandString = "SELECT * FROM EquipAlarmEvent WHERE Event = 'True' AND DateIn >= '" + DTIn + "' AND DateIn <= '" + DTOut + "' ORDER BY Id DESC;";

       SqlConnection Call = new SqlConnection(ConnectionString);

       SqlDataAdapter Adapter = new SqlDataAdapter(CommandString, ConnectionString);

       Adapter.Fill(Data);
      } catch (Exception ex) {
       Screen.Window_Buffer_Diagnostic.List_Error = ex.ToString();
      }

      return RemoveUnderscoreAndSubscribeDate(Data);
    
asked by anonymous 08.06.2017 / 22:52

0 answers