- Home /
SQLite Question: How to only show the elements I want
Run into another roadblock with SQLite. I want to only display those items that were "selected", but I'm getting an error so something is not right. Any help would be appreciated. Thanks!
mSQLString = "SELECT " + COL_EQUIPMENT_INCLUDE + " FROM " + SQL_TABLE_THE_EQUIPMENT + " WHERE" + COL_EQUIPMENT_INCLUDE + " =" + "1" + "";
When an item is selected via a toggle, it's saved to the database as a 0 or 1. I only want to show those that have the 1 in that column. The output shows all items both those that are selected and those that are not.
Now there is a new issue: IndexOutOfRangeException: Array index is out of range. $$anonymous$$ono.Data.SqliteClient.SqliteDataReader.GetString (Int32 i)
Do I need to use a variable x=1 rather than just using 1? Thanks!
Answer by jgodfrey · Mar 16, 2016 at 07:22 PM
If you write out the value of the mSQLString, you'll see that you have (at least) a spacing problem behind your "WHERE" keyword (it runs right into the column name). That said, you didn't mention what the actual error is, so I'm just guessing.
Anyway, print out your constructed string to see it in its final form and fix the spacing issues.
Well, of course. Have you fixed what @jgodfrey has mentioned? Specifically this:
+ " WHERE" +
should be this:
+ " WHERE " +
Also it's common to wrap column names in quotation marks. However if it's a single word it usually should work as long that word isn't a reserved word.
Yes the correction was made, but now it's giving me an index out of range error...
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How Do I Turn Off Toggle in a ToggleGroup ? 1 Answer
SQLite Sort Ascending order 0 Answers
[C#]Toggle Run on/off 2 Answers