title: Crystal Reports (C#) : Informations not displaying correctly
body: <p>I'll separate this post in 3 sections to be as clear as possible. The first one will be informations you need to know. Second one will be the solutions I tried so far to get this working. Third section will be the questions. I also have to precise that's the first time I'm using CrystalReports.</p>
  
  <h2>Informations</h2>
  
  <p>I'm currently working with Visual Studio 2010 with C# and I'm using SAP Crystal reports. I'm displaying the data using MySQL database. </p>
  
  <p>Now, here are the tables I use to display the report:</p>
  
  <pre><code>Table : orders
  Fields : id(primaryKey), date(DATE), quantity(INT), fksizes(INT), fkclients(INT)
  
  Table : sizes
  Fields : id(primaryKey), name(VARCHAR(30)), price(FLOAT)
  
  Relationship between these 2 tables : orders.fksizes with sizes.id
  </code></pre>
  
  <p>Basically, I'm passing a range of dates as parameters to the Crystal Reports to display informations only between those dates. Then, I created 2 parameters : <code>StartDate</code> and <code>EndDate</code> both of type <code>Date</code>.</p>
  
  <h2>What I've tried</h2>
  
  <p>Here's the original query I'm using to display what I want without the date range condition :</p>
  
  <pre><code>SELECT sizes.name, SUM(orders.quantity) AS totalQty,
     (SUM(sizes.price) * orders.quantity) AS totalPrice, 
     orders.date 
  FROM orders 
      INNER JOIN sizes ON orders.fksizes = sizes.id
  GROUP BY sizes.name, orders.date
  </code></pre>
  
  <p>This query works correctly and display the total quantity sold and the total price for each size name. At the report's footer, I'm using a Summary field in which I got the total sum of all <code>totalQty</code> named <code>sumTotalQty</code>. I have another field for the same purpose for <code>totalPrice</code> named <code>sumTotalPrice</code>.</p>
  
  <p>I have 2 rows of data test which are :</p>
  
  <pre><code>Size name                     Quantity sold                      Total Price
  ------------------------------------------------------------------------------
  Big                           2                                  $6.00
  XBig                          7                                  $28.00  
  </code></pre>
  
  <p>The field <code>sumTotalQty</code> displays <code>9</code> and <code>sumTotalPrice</code> displays <code>$34.00</code> which is exact results. I have to precise that the first row has <code>2013-10-29</code> as value for <code>orders.date</code> and the second one <code>2013-10-30</code>.</p>
  
  <p>Now, I want to select a range of dates for which I want to display the results. As an example, I select from <code>2013-10-30</code> to today, I should get only the second row with <code>sumTotalQty</code> displaying <code>7</code> and <code>sumTotalPrice</code> displaying <code>$28.00</code>. I got the single row correctly displayed, but <code>sumTotalQty</code> displaying <code>9</code> and <code>sumTotalPrice</code> displaying <code>$34.00</code> which are incorrect following the date range.</p>
  
  <p>I then tried to add a WHERE clause to my sql query to specify the date range like this (in Database --> Database expert...):</p>
  
  <pre><code>SELECT sizes.name, SUM(orders.quantity) AS totalQty,
     (SUM(sizes.price) * orders.quantity) AS totalPrice, orders.date 
  FROM orders 
      INNER JOIN sizes ON orders.fksizes = sizes.id
  WHERE orders.date BETWEEN '{?StartDate}' AND '{?EndDate}'
  GROUP BY sizes.name, orders.date
  </code></pre>
  
  <p>I got no result displayed with it. So, I think <code>{?StartDate}</code> and <code>{?EndDate}</code> are just not set but I'm really not sure. The same goes for <code>WHERE orders.date BETWEEN @StartDate AND @EndDate</code>.</p>
  
  <h2>Questions</h2>
  
  <ol>
  <li>Why aren't <code>{?StartDate}</code> and <code>{?EndDate}</code> set even if I have entered a date range when I'm prompted to give them ?</li>
  <li>With the original query (without the WHERE clause), how can I get the right result in my summarize fields with the date range given ? It's like it sums from the database and not from the report fields.</li>
  </ol>
  
  <p><strong>EDIT</strong>
  After many searches, 2 other questions came in my head :</p>
  
  <ol>
  <li><p>Is it possible to add <code>DateTimePicker</code> in the report so the user will be able to enter a starting date and an end date easily ? The report would be refreshed automatically after that.</p></li>
  <li><p>Is there a way to create or use Crystal Reports events (<code>OnLoad</code>, <code>AfterLoad</code>,...) ?</p></li>
  </ol>
  
  <p>Thank you for all help I'll get.</p>