title: SqlDataReader does not work - does not read data
body: <p>I have a <code>SqlDataReader</code>, but it never enters into <code>Read()</code>.</p>
  
  <p>When I debug it, it pass the loop <code>while(readerOne.Read())</code>. It never enter into this loop even though there is data.</p>
  
  <pre><code>public static List&lt;Pers_Synthese&gt; Get_ListeSynthese_all(string codeClient, DateTime DateDeb, DateTime DateFin)
  {
     try
     {
        using (var connectionWrapper = new Connexion())
        {
           var connectedConnection = connectionWrapper.GetConnected();
  
           string sql_Syntax = Outils.LoadFileToString(Path.Combine(appDir, @"SQL\Get_ListeSynthese_All.sql"));
  
           SqlCommand comm_Command = new SqlCommand(sql_Syntax, connectionWrapper.conn);
           comm_Command.Parameters.AddWithValue("@codeClioent", codeClient);
           comm_Command.Parameters.AddWithValue("@DateDeb", DateDeb);
           comm_Command.Parameters.AddWithValue("@DateFin", DateFin);
  
           List&lt;Pers_Synthese&gt; oListSynthese = new List&lt;Pers_Synthese&gt;();
  
           SqlDataReader readerOne = comm_Command.ExecuteReader();
  
           while (readerOne.Read())
           {
              Pers_Synthese oSyntehse = new Pers_Synthese();
              oSyntehse.CodeTrf = readerOne["CODE_TARIF"].ToString();
              oSyntehse.NoLV = readerOne["NOID"].ToString();
              oSyntehse.PrxUnitaire = readerOne["PRIX_UNITAIRE"].ToString();
              oSyntehse.ZoneId = readerOne["LE_ZONE"].ToString();
              oSyntehse.LeZone = readerOne["LIB_ZONE"].ToString();
              oSyntehse.LeDept = readerOne["DEPT"].ToString();
              oSyntehse.LeUnite = readerOne["ENLEV_UNITE"].ToString();
              oSyntehse.LePoids = Convert.ToInt32(readerOne["POID"]);
              //oSyntehse.LePoidsCorr = Convert.ToInt32(readerOne["POID_CORR"]);
              oSyntehse.LeColis = readerOne["NBR_COLIS"].ToString();
              oSyntehse.LeCr = readerOne["NBR_CREMB"].ToString();
              oSyntehse.SumMontantCR = readerOne["ENLEV_CREMB"].ToString();
              oSyntehse.LeVd = readerOne["NBR_DECL"].ToString();
              oSyntehse.SumMontantVD = readerOne["ENLEV_DECL"].ToString();
              oSyntehse.LePrixHT = readerOne["PRIX_HT"].ToString();
              oSyntehse.LePrixTTC = readerOne["PRIX_TTC"].ToString();
              oSyntehse.TrDeb = readerOne["TR_DEB"].ToString();
              oSyntehse.TrFin = readerOne["TR_FIN"].ToString();
  
              oListSynthese.Add(oSyntehse);
           }
           readerOne.Close();
           readerOne.Dispose();
           return oListSynthese;
        }
    }
    catch (Exception excThrown)
    {
       throw new Exception(excThrown.Message);
    }
  }
  </code></pre>
  
  <p>When I debug it with SQL Server profiler it shows the data....that meant the data is not empty, but it never enter into this loop.</p>
  
  <pre><code>while (readerOne.Read())
  {
  </code></pre>
  
  <p>by the way my connection class:</p>
  
  <pre><code> class Connexion : IDisposable 
      {
          public SqlConnection conn;
          public SqlConnection GetConnected()
          {
              try
              {
                  string strConnectionString = Properties.Settings.Default.Soft8Exp_ClientConnStr;
                  conn = new SqlConnection(strConnectionString);
              }
              catch (Exception excThrown)
              {
                  conn = null;
                  throw new Exception(excThrown.InnerException.Message, excThrown);
              }
  
              // Ouverture et restitution de la connexion en cours
              if (conn.State == ConnectionState.Closed) conn.Open();
              return conn;
          }
  
          public Boolean IsConnected
          {
              get { return (conn != null) &amp;&amp; (conn.State != ConnectionState.Closed) &amp;&amp; (conn.State != ConnectionState.Broken); }
          }
  
          public void CloseConnection()
          {
              // Libération de la connexion si elle existe
              if (IsConnected)
              {
                  conn.Close();
                  conn = null;
  
              }
  
          }
  
          public void Dispose()
          {
              CloseConnection();
          }
      }
  </code></pre>
  
  <p>and my SQL Statement:</p>
  
  <pre><code>exec sp_executesql N'SELECT CODE_TARIF,PRIX_UNITAIRE,TR_DEB,TR_FIN,LE_ZONE,T_TARIF_ZONE.LIBELLE as LIB_ZONE,
    SUBSTRING(CP_DEST,1,2) as DEPT,T_UNITE.LIBELLE as ENLEV_UNITE,
    count(NOID)as NOID,
     SUM(CASE WHEN POID_CORR IS NOT NULL THEN POID_CORR ELSE POID END) as POID,sum(NBR_COLIS)as NBR_COLIS,COUNT(NULLIF(ENLEV_CREMB,0))as NBR_CREMB, sum(ENLEV_CREMB)as ENLEV_CREMB,COUNT(NULLIF(ENLEV_DECL,0))as NBR_DECL,sum(ENLEV_DECL)as ENLEV_DECL,sum(PRIX_HT)as PRIX_HT,sum(PRIX_TTC)as PRIX_TTC, sum (POID_CORR)as POID_CORR
    FROM LETTRE_VOIT_FINAL
     LEFT JOIN T_TARIF_ZONE ON LETTRE_VOIT_FINAL.LE_ZONE = T_TARIF_ZONE.NO_ID
    LEFT JOIN T_UNITE ON LETTRE_VOIT_FINAL.ENLEV_UNITE = T_UNITE.NO_ID
    where code_client = @codeClioent
     and DATE_CLOTUR_REEL BETWEEN @DateDeb AND @DateFin
     and STATUT_LV = 2
  
   group by CODE_TARIF,PRIX_UNITAIRE,TR_DEB,TR_FIN,LE_ZONE,T_TARIF_ZONE.LIBELLE,SUBSTRING(CP_DEST,1,2),T_UNITE.LIBELLE
   order by LE_ZONE,PRIX_UNITAIRE
  
  ',N'@codeClioent nvarchar(8),@DateDeb datetime,@DateFin datetime',@codeClioent=N'17501613',@DateDeb='2013-06-05 00:00:00',@DateFin='2013-06-05 23:59:00'
  </code></pre>
  
  <p>it return the data on SQL profiler:
  <img src="https://i.stack.imgur.com/S6YBh.jpg" alt="enter image description here"></p>
  
  <p>my real query :</p>
  
  <pre><code>SELECT CODE_TARIF,PRIX_UNITAIRE,TR_DEB,TR_FIN,LE_ZONE,T_TARIF_ZONE.LIBELLE as LIB_ZONE,
    SUBSTRING(CP_DEST,1,2) as DEPT,T_UNITE.LIBELLE as ENLEV_UNITE,
    count(NOID)as NOID,
     SUM(CASE WHEN POID_CORR IS NOT NULL THEN POID_CORR ELSE POID END) as POID,sum(NBR_COLIS)as NBR_COLIS,COUNT(NULLIF(ENLEV_CREMB,0))as NBR_CREMB, sum(ENLEV_CREMB)as ENLEV_CREMB,COUNT(NULLIF(ENLEV_DECL,0))as NBR_DECL,sum(ENLEV_DECL)as ENLEV_DECL,sum(PRIX_HT)as PRIX_HT,sum(PRIX_TTC)as PRIX_TTC, sum (POID_CORR)as POID_CORR
    FROM LETTRE_VOIT_FINAL
     LEFT JOIN T_TARIF_ZONE ON LETTRE_VOIT_FINAL.LE_ZONE = T_TARIF_ZONE.NO_ID
    LEFT JOIN T_UNITE ON LETTRE_VOIT_FINAL.ENLEV_UNITE = T_UNITE.NO_ID
    where code_client = @codeClioent
     and DATE_CLOTUR_REEL BETWEEN @DateDeb AND @DateFin
     and STATUT_LV = 2
  
   group by 
  
      CODE_TARIF,PRIX_UNITAIRE,TR_DEB,TR_FIN,LE_ZONE,T_TARIF_ZONE.LIBELLE,SUBSTRING(CP_DEST,1,2),T_UNITE.LIBELLE
       order by LE_ZONE,PRIX_UNITAIRE
  </code></pre>
  
  <p>it is strange....when the data is between :</p>
  
  <pre><code>DATE_CLOTUR_REEL BETWEEN '2013-06-05 00:00:00' and '2013-06-05 23:59:00'
  </code></pre>
  
  <p>but </p>
  
  <pre><code>DATE_CLOTUR_REEL BETWEEN '2013-06-01 00:00:00' and '2013-06-05 23:59:00'
  </code></pre>
  
  <p>it works.</p>