Note that there are some explanatory texts on larger screens.

plurals
  1. POSqlite query not returning expected values ( Values should be <1000 but are not)
    primarykey
    data
    text
    <p>Technology is winforms, using c# and sqlite as my database. I'm running this query:</p> <pre><code> string sql6 = "select YYMM, TotalTrans from t2 where cast(TotalTrans as Real) &lt; 1000.00"; </code></pre> <p>I then take the results from the query and populate them into lists, which i then use to populate a listview. </p> <p><em><strong>Problem:</strong> The results from column TotalTrans appear to be obviously greater than 1000, as I'm getting a ton of numbers which are even in the 100000s.</em></p> <p><strong>What I tried to do to fix it:</strong> Tried to cast twice because I thought for some reason the TotalTrans column wasn't being converted to float. </p> <pre><code> string sql6 = "select YYMM, cast(TotalTrans as Real) from t2 where cast(TotalTrans as Real) &lt; 1000.00"; </code></pre> <p>However this only made it worse as I got another problem : "Index was out of bounds of Array" in the following code (located in the "reader3["TotalTrans"] part.</p> <pre><code> string sql6 = "select YYMM, cast(TotalTrans as Real) from t2 where cast(TotalTrans as Real) &lt; 1000.00"; SQLiteCommand command3 = new SQLiteCommand(sql6, sqlite_conn); SQLiteDataReader reader3 = command3.ExecuteReader(); while (reader3.Read()) { double TotalTrans; DateTime yyyymm; if (DateTime.TryParse(reader3["YYMM"].ToString(), out yyyymm) &amp;&amp; double.TryParse(reader3["TotalTrans"].ToString(), out TotalTrans)) { YYMM.Add(yyyymm); TotalTransIrregularities.Add(TotalTrans); } } </code></pre> <p><strong>Note:</strong></p> <p>This is a side problem, but the main issue is the original problem I posted. The query should return values &lt;1000 but it is obviously not. When I tried to fix it using my approach I got another problem which said the index was out of bounds of the array. Whats the best fix? Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload